I use Freemarker 2.3.23 and I want to print a string representation of XML. So, I've found outputformat directive. But when I try to use it, I have following ParseException:
Unknown directive: #outputformat. Help (latest version): http://freemarker.org/docs/ref_directive_alphaidx.html; you're using FreeMarker 2.3.23.
at freemarker.core.TokenMgrError.toParseException(TokenMgrError.java:247)
at freemarker.template.Template.<init>(Template.java:215)
at freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:495)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:409)
at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:261)
at freemarker.template.Configuration.getTemplate(Configuration.java:1786)
at freemarker.template.Configuration.getTemplate(Configuration.java:1646)
Snippet of my template.ftlh file:
<div class="well">
<#outputformat 'XML'>${testCase.response}</#outputformat>
</div>
You need at least 2.3.24 for outputformat
.
Note that you should only need <#outputformat ...>
rarely, if ever. Usually you just configure FreeMarker to use XML output format everywhere by default. If different templates need different output formats, then you can associate the output formats to template file extensions or other name patterns. If even that's not flexible enough, you can use <#ftl output_format='XML'>
header.