FreeMarker: keep identation when using macros

cherih

New Member
i'm using the FreeMarker template engine to generate some php classes from an abstract description of a webservice. My problem is, when i call a macro in a FreeMarker template, the macro inserts the text without the lefthand whitespace before the macro call.exampleTemplate.ftl:\[code\]<?php class ${class.name} { <@docAsComment class.doc/> <#list class.fields as field> $${field.name}; </#list> <#-- ... --> }?><#macro docAsComment doc>/*<#if doc.title != "">* ${doc.title}</#if><#list doc.content as content><#if content != ""> * ${content}</#if></#list>*/</#macro>\[/code\]This will generate something like this:\[code\]<?php class foo {/* * foo * bar foo, bla */ $a; $b; }?>\[/code\]One solution would be, to submit the leading whitespace as an argument to the macro, but that makes the template only more unreadable. Is there a better solution?
 
Back
Top