Re: escape nested content in macro?

Erin Drummond <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
How come you need to use a macro at all if all you're doing is
escaping a javascript string?

var v = "${x?js_string}"
//do something with v in javascript

Unless what you're trying to escape isnt in a variable. But it would
have to be if you were passing it to a macro.
Unless you're passing it as nested content. In which case, why cant
you use <#assign> to get into a variable and run ?js_string on it? I
dont understand why you cant assign the text to a variable using
#assign

<#macro my_macro>
<#assign the_nested_crap>
<#nested>
</#assign>
var v = "${the_nested_crap?js_string}"
//do something with v
</#macro>

<@my_macro>
I ""will"" be 'escaped'
</@my_macro>

On Sat, Nov 6, 2010 at 4:01 PM, EC <[email protected]> wrote:
> Hi,
> I have a macro that needs to escape as javascript its nested content.
> Calling:
> <@my_macro>
> This "text"
> Needs to be 'escaped' for JS
> </@my_macro>
> I tried things such as:
> <#macro my_macro>
> var v = "<#escape x as x?js_string><#nested></#escape>";
> // do something with v
> </#macro>
> But I cannot get anything to work. How do I do something like that without
> defining the text as a variable using assign?
> Thanks
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
>

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.