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

Daniel Dekany edited comment on FREEMARKER-20 at 4/19/16 8:12 PM:
------------------------------------------------------------------

This is one of the cases which won't give the intuitive result without dynamic 
(run time) white-space handling, however, the architecture of FreeMarker 2 
can't implement that, not in the general cases anyway. It's considered for 
FreeMarker 3, because, I believe, it requires breaking backward compatibility 
(as we can't use simple {{Writer}}-s anymore, except for the final outputting 
stage).

BTW, the

{code}
${"                "}
{code}

is not needed, you can just include those spaces literally. But the 3 line 
variation is nicer anyway. 


was (Author: ddekany):
This is one of the cases which won't give the intuitive result without dynamic 
(run time) white-space handling, however, the architecture of FreeMarker 2 
architecture can't implement that, not in the general cases anyway. It's 
considered for FreeMarker 3, because, I believe, it requires breaking backward 
compatibility (as we can't use simple {{Writer}}-s anymore, except for the 
final outputting stage).

BTW, the

{code}
${"                "}
{code}

is not needed, you can just include those spaces literally. But the 3 line 
variation is nicer anyway. 

> Some single-line solution to avoid empty lines 
> -----------------------------------------------
>
>                 Key: FREEMARKER-20
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-20
>             Project: Apache Freemarker
>          Issue Type: New Feature
>          Components: engine
>    Affects Versions: 2.3.23
>            Reporter: Ondra Žižka
>
> I'd like to be able to have the NEW LINE generated conditionally, with 1 line 
> of template source code.
> I haven't found a way. 
> {code}
>             <#if 
> dep.classifier??><classifier>${dep.classifier}</classifier></#if>
> {code}
> This generates the indent spaces and the newline, no matter what.
> {{#t}} and {{#rt}} and {{#lt}} apply at compile time, so they don't care 
> about the condition. So they strip even if the content is there, which I 
> don't want.
> I could do this:
> {code}
>             <#if dep.classifier??>${"            
> "}<classifier>${dep.classifier}</classifier>${"\n"}</#if><#t>
> {code}
> So that's the request. It can also be anything what helps me achieve that.
> Until then, I have to do:
> {code}
>             <#if dep.classifier??>
>             <classifier>${dep.classifier}</classifier>
>             </#if>
> {code}
> Which I don't like because it makes the templates way longer.
> Or
> {code}
>             <#if dep.classifier??><classifier>${dep.classifier}</classifier>
>             </#if><#if 
> dep.classifier??><classifier>${dep.classifier}</classifier>
>             </#if>
>             ...
> {code}
> Which I don't like because it's messy.
> Or 
> {code}
>              <#if dep.classifier??>${"         
> "}<classifier>${dep.classifier}</classifier>${"\n"}</#if><#t>
> {code}
> Which I don't like because it adds superfluous pieces to the template.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to