blob: cf484752d8bb5d660ac090091fadb7ca9f99784a [file] [log] [blame]
<!doctype html>
<!-- Generated by FreeMarker/Docgen from DocBook -->
<html lang="en" class="page-type-section">
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<title>Old FTL syntax - FreeMarker Manual</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="format-detection" content="telephone=no">
<meta property="og:site_name" content="FreeMarker Manual">
<meta property="og:title" content="Old FTL syntax">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="http://example.com/ref_depr_oldsyntax.html">
<link rel="canonical" href="http://example.com/ref_depr_oldsyntax.html">
<link rel="icon" href="favicon.png" type="image/png">
<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1594338517553">
</head>
<body itemscope itemtype="https://schema.org/Code">
<meta itemprop="url" content="http://example.com/">
<meta itemprop="name" content="FreeMarker Manual">
<!--[if lte IE 9]>
<div style="background-color: #C00; color: #fff; padding: 12px 24px;">Please use a modern browser to view this website.</div>
<![endif]--><div class="header-top-bg"><div class="site-width header-top"><a class="logo" href="http://example.com" role="banner"> <img itemprop="image" src="logo.png" alt="My Logo">
</a></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">FreeMarker Manual</a><div class="navigation-header"></div></div><div class="site-width breadcrumb-row"><ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref.html"><span itemprop="name">Reference</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_deprecated.html"><span itemprop="name">Deprecated FTL constructs</span></a></li><li class="step-3" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_depr_oldsyntax.html"><span itemprop="name">Old FTL syntax</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="ref.html">Reference</a></li><li><a href="app_faq.html">FAQ</a></li><li><a href="preface.html#test_target">Bőregér</a></li></ul></div></div></div> <div class="main-content site-width">
<div class="content-wrapper no-toc">
<div id="table-of-contents-wrapper" class="col-left">
</div>
<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="ref_depr_transform.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_depr_numerical_interpolation.html"><span>Next</span></a></div><div class="title-wrapper">
<h1 class="content-header header-section1" id="ref_depr_oldsyntax" itemprop="headline">Old FTL syntax</h1>
</div></div><p>With the old FTL syntax the <code class="inline-code">#</code> was not
required (prior 2.1 not even allowed) in the FTL tags. For example,
you could write this:</p>
<div class="code-wrapper"><pre class="code-block code-template">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Welcome!&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Welcome ${user}!&lt;/h1&gt;
&lt;p&gt;We have there animals:
&lt;ul&gt;
<strong>&lt;list animals as being&gt;</strong>
&lt;li&gt;${being.name} for ${being.price} Euros
<strong>&lt;/list&gt;</strong>
&lt;/ul&gt;
<strong>&lt;include &quot;common_footer.html&quot;&gt;</strong>
&lt;/body&gt;
&lt;/html&gt;</pre></div><p>While the <code class="inline-code">#</code>-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&#39;&#39;), the
<code class="inline-code">#</code> is strictly required. That is, things like
<code class="inline-code">&lt;include &quot;common_footer.html&quot;&gt;</code> will go to the
output as is, since they are not considered as FTL tags. Note that
user-defined directives use <code class="inline-code">@</code> <em>instead
of</em> <code class="inline-code">#</code>.</p><p>However, to give users time to prepare for this change, in
FreeMarker 2.1 and 2.2 the usage of <code class="inline-code">#</code> is optional,
unless the programmer enables strict syntax mode in the FreeMarker
configuration by calling <code class="inline-code">setStrictSyntaxMode(true)</code>
on <code class="inline-code">Configuration</code>. In fact, we strongly recommend
this to programmers. Starting from some later release this setting
will be initially set to <code class="inline-code">true</code>. Also, you can
specify if you want to use strict syntax or old syntax in the template
files with the <a href="ref_directive_ftl.html#ref.directive.ftl"><code>ftl</code>
directive</a>.</p><p>The advantages of ``strict syntax&#39;&#39; over the legacy FTL syntax
are:</p><ul>
<li>
<p>Since all
<code class="inline-code">&lt;#<em class="code-color">...</em>&gt;</code> and
<code class="inline-code">&lt;/#<em class="code-color">...</em>&gt;</code> are
reserved for FTL:</p>
<ul>
<li>
<p>We can introduce new directives without breaking
backward compatibility.</p>
</li>
<li>
<p>We can detect if you made a typo, i.e.
<code class="inline-code">&lt;#inculde
<em class="code-color">...</em>&gt;</code> is treated as
parse-time error, rather than silently treated as simple
text.</p>
</li>
<li>
<p>It is easier for third-party tools to handle templates
(e.g. do syntax highlighting), especially since they don&#39;t
have to know about the new directives introduced with new
releases.</p>
</li>
<li>
<p>Templates are more readable, since it is easier to spot
<code class="inline-code">&lt;#...&gt;</code> tags embedded into HTML or
other markup.</p>
</li>
</ul>
</li>
<li>
<p><code class="inline-code">&lt;#</code> and <code class="inline-code">&lt;/#</code> is
illegal XML (except in CDATA sections), and illegal in almost all
other SGML applications, so they can&#39;t interfere with the tags
used in the static text parts (e.g. if you have
<code class="inline-code">include</code> element in the generated XML).</p>
</li>
</ul><div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="ref_depr_transform.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_depr_numerical_interpolation.html"><span>Next</span></a></div></div></div></div> </div>
</div>
<div class="site-footer"><div class="site-width"><div class="footer-bottom"> <p class="last-generated">
Last generated:
<time itemprop="dateModified" datetime="2020-07-09T23:48:37Z" title="Thursday, July 9, 2020 11:48:37 PM GMT">2020-07-09 23:48:37 GMT</time> </p>
<p class="copyright">
© <span itemprop="copyrightYear">1999</span>–2020
<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="https://apache.org/">The Apache Software Foundation</a> </p>
</div></div></div></body>
</html>