Re: Escape html inside recurse / visit directive
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, September 1, 2009, 11:35:25 PM, Ista Pouss wrote:
> Hi,
>
> I have some recurse and visit directive to process xml document.
>
> I don't understand where I can put some foo?html or <#escape>
> </#escape> to transform text nodes ?
>
> I have some directives like :
>
> <#visit textDOM(value)/>
>
> <#macro descf>
> <#recurse>
> </#macro>
>
> <#macro citation>
> <i><#recurse></i>
> </#macro>
>
> ... to process desc and citation elements, for instance, but nothing
> to process text node : freemarker do that for me I suppose.
FreeMarker defines a default node handler for text, but it should be
overridden if you generate XML or HTML, for the reason you said...
> But how escape it ?
As you might know #escape only affects the ${...}. What is important
to realize that it affects only those ${...}-s that are between the
<#escape ...> and </#escape> in the template source code (not on
runtime). With other words, #escape is a pre-processor directive that
affects the template itself, and has no direct runtime effect. So
#escape doesn't influence how text nodes are printed, unless the
source code of the macro that handler the text node is inside the
#escape, again, in the source code. So, you should have one of these:
<#escape x as x?html>
...
<#macro @text>${.node}</#macro>
...
</#escape>
and
<#-- No #escape around -->
<#macro @text>${.node?html}</#macro>
> Thanks.
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july