How to Create a Macro in FreeMarker

<#macro sample param1 param2>
  <Item>
    <Field1>${param1}</Field1>
    <Field2>${param2}</Field2>
  </Item>
</#macro>
<?xml version="1.0" encoding="UTF-8"?>
<List>
  <#list list as item>
    <@sample param1="${...}" param2="SampleTemplateMethodModel"?new()() />
  </#list>
</List>

http://freemarker.sourceforge.net/docs/ref_directive_macro.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s