You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by "Daniel Dekany (JIRA)" <ji...@apache.org> on 2016/04/19 22:12:25 UTC
[jira] [Commented] (FREEMARKER-20) Some single-line solution to
avoid empty lines
[ https://issues.apache.org/jira/browse/FREEMARKER-20?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15248528#comment-15248528 ]
Daniel Dekany commented on FREEMARKER-20:
-----------------------------------------
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)