[ 
https://issues.apache.org/jira/browse/FREEMARKER-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16705736#comment-16705736
 ] 

Daniel Dekany commented on FREEMARKER-110:
------------------------------------------

You can't query if the invocation has specified a nested content or not, by 
design. That has the same reason why in XML {{<foo></foo>}} and {{<foo/>}} are 
indistinguishable when you process XML. It would be less a problematic design 
decision to be able to query if the nested content is 0 length, but it leads to 
edge cases that the users of such a macro (a macro that cares about whether the 
nested content is empty) will be confused about, such as when the body is not 
empty but: (a) contains only whitespace; (b) contains only comments (and 
whitespace); (c) contains other directive calls that do not produce output on 
runtime. Therefore, if you really, really need to do such a check, then it's 
better be a case where the question is really if the output produced by the 
nested content is discardable. In such case, you should capture the nested 
output like {{<#local nestedOutput><#nested></#local>}}, then check if 
{{nestedOutput}} is empty (after trimming), then print it with  
{{$\{nestedOutput}}}. (Be careful with auto-escaping, if you use that.)

> describe how to test whether "nested" in a macro is empty or not
> ----------------------------------------------------------------
>
>                 Key: FREEMARKER-110
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-110
>             Project: Apache Freemarker
>          Issue Type: Improvement
>            Reporter: Ralf Hauser
>            Priority: Major
>
> [https://freemarker.apache.org/docs/ref_directive_macro.html#autoid_106]
>  
> Then, I could put something else, if I know that no nested content is coming



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to