28

I am working on a freemarker template and here is a sample.

<Grantor>
    <UniqueID>${(currentGrantorIndex)!?string}</UniqueID> // want to comment this line
    <Entity>${(grantor.entityTypeName)!?string}</Entity>
</Grantor>

I want to know how to write comments or comment out few lines in freemarker templates. Any idea?

SikanderAhmed
  • 361
  • 1
  • 5
  • 14

2 Answers2

48

Comment in freemarker are delimited by <#-- and -->. Everything between these delimiters will not be interpreted by freemarker and won't appear in the output.

<Grantor>
    <#-- <UniqueID>${(currentGrantorIndex)!?string}</UniqueID> -->
    <Entity>${(grantor.entityTypeName)!?string}</Entity>
</Grantor>

See freemarker reference here.

obourgain
  • 8,856
  • 6
  • 42
  • 57
1

Another non-standard way of adding comments in freemarker using the if tag:

<#if 1=0>comment</#if>

or

<#if false>comment</#if>
Rohit
  • 392
  • 3
  • 14