With the old FTL syntax the # was not required (prior 2.1 not even allowed) in the FTL tags. For example, you could write this:
![]() | ![]() | ![]() | |
![]() |
| ![]() | |
![]() | ![]() | ![]() |
While the #-less syntax was more natural for HTML authors, it had too many drawbacks, so finally we have decided to deprecate it. With the newer syntax (a.k.a ``strict syntax''), the # is strictly required. That is, things like <include "common_footer.html"> will go to the output as is, since they are not considered as FTL tags. Note that user-defined directives use @ instead of #.
However, to give users time to prepare for this change, in FreeMarker 2.1 and 2.2 the usage of # is optional, unless the programmer enables strict syntax mode in the FreeMarker configuration by calling setStrictSyntaxMode(true) on Configuration. In fact, we strongly recommend this to programmers. Starting from some later release this setting will be initially set to true. Also, you can specify if you want to use strict syntax or old syntax in the template files with the ftl directive.
The advantages of ``strict syntax'' over the legacy FTL syntax are:
Since all <#...> and </#...> are reserved for FTL:
We can introduce new directives without breaking backward compatibility.
We can detect if you made a typo, i.e. <#inculde ...> is treated as parse-time error, rather than silently treated as simple text.
It is easier for third-party tools to handle templates (e.g. do syntax highlighting), especially since they don't have to know about the new directives introduced with new releases.
Templates are more readable, since it is easier to spot <#...> tags embedded into HTML or other markup.
<# and </# is illegal XML (except in CDATA sections), and illegal in almost all other SGML applications, so they can't interfere with the tags used in the static text parts (e.g. if you have include element in the generated XML).