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

Daniel Dekany commented on FREEMARKER-82:
-----------------------------------------

More intelligent indentation would be a great feature for sure, but that 
involves deciding the indentation on run time. Back then when I was thinking 
about it, and found that you ran into limitations if things just print into a 
`Writer` internally. Instead, you need a stream of fragments with richer 
semantics, so that you can tell if a fragment is indentation that might can be 
removed, and so on. As not using a `Writer` in API-s like 
`TemplateDirectiveModel` is not backward compatible, this issue was postponed 
to FreeMarker 3 (which however haven't yet reached the state where this will be 
attempted). But maybe there's a less perfect solution that works with 
`Writer`-s... I don't know, will have to think about it. (Also, I tried it 
without any directives, just generating the output that a human would expect.)

> A new whitespace tag to indicate the baseline indentation for <@macro> and 
> includes.
> ------------------------------------------------------------------------------------
>
>                 Key: FREEMARKER-82
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-82
>             Project: Apache Freemarker
>          Issue Type: Wish
>          Components: engine
>            Reporter: Brent
>
> Sometimes, perhaps most of the times, it is useful to split up small pieces 
> of my template into macros or otherwise other templates to include.
> However, since V2.3, lines containing only FTL tags get trimmed. This is 
> annoying because I may want to include a macro or another template, with the 
> current indentation of where I call it.
> This brings me to my next point, as shown in [my answer on 
> StackOverflow|https://stackoverflow.com/a/46973468/2686165], it is possible 
> to keep this indentation with <#nt>, but this only works for the first line 
> of the macro (see SO answer at the bottom).
> So I propose an easy way to say "use the current indentation of the line, as 
> a base of all the indentation for my macro or included template.
> Any indentation inside the included template, or the macro would be relative. 
> If one wished to break the relative indentation for a line inside their 
> included template or macro, another tag should be foreseen to indicate that.
> New tags:
> * To indicate an indentation base for templates/macros
> * To indicate that a line inside the included template/macro must not use the 
> indentation base (so you can put lines that don't follow the indentation, 
> perhaps <#t> already provides this functionality)



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to