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

Brent edited comment on FREEMARKER-81 at 10/27/17 12:15 PM:
------------------------------------------------------------

Well, perhaps it is "supposed to work" like that, but it is illogical.

Consider that I have this template:


{code:java}
<#macro someStatements>
System.out.println("hello");
System.out.println("world");
</#macro>

void test() {
    <@someStatements />
}
{code}


I will receive the following result:


{code:java}
void test() {
System.out.println("hello");
System.out.println("world");
}
{code}


The fix to keep indentation was to use <#nt>:

{code:java}
void test() {
    <@someStatements /><#nt>
}
{code}


Expected result:

{code:java}
void test() {
    System.out.println("hello");
    System.out.println("world");
}
{code}

Actual result:

{code:java}
void test() {
    System.out.println("hello");
System.out.println("world");
}
{code}



was (Author: brentc):
Well, perhaps it is "supposed to work" like that, but it is illogical.

Consider that I have this template:

<#macro someStatements>
System.out.println("hello");
System.out.println("world");
</#macro>

void test() {
    <@someStatements />
}

I will receive the following result:

void test() {
System.out.println("hello");
System.out.println("world");
}

The fix to keep indentation was to use <#nt>:
void test() {
    <@someStatements /><#nt>
}

Expected result:
void test() {
    System.out.println("hello");
    System.out.println("world");
}
Actual result:
void test() {
    System.out.println("hello");
System.out.println("world");
}

> <#nt> in combination with a <@macro > directive, only keeps indentation for 
> the first line
> ------------------------------------------------------------------------------------------
>
>                 Key: FREEMARKER-81
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-81
>             Project: Apache Freemarker
>          Issue Type: Bug
>          Components: engine
>            Reporter: Brent
>
> <#nt> in combination with a <@macro > directive, only keeps indentation for 
> the first line. Multiple lines in the macro, will put every line except the 
> first without indentation.
> I actually propose a neater way to keep indentation of the line where 
> <@macro> is used, to use as baseline for the entire macro.
> See my post on StackOverflow for an example: 
> https://stackoverflow.com/a/46973468/2686165



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

Reply via email to