You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/03/13 10:58:02 UTC
[26/50] incubator-freemarker-site git commit: 2.3.26-nightly docs
preview
http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/52c070a9/builds/2.3.26-nightly/ref_builtins_node.html
----------------------------------------------------------------------
diff --git a/builds/2.3.26-nightly/ref_builtins_node.html b/builds/2.3.26-nightly/ref_builtins_node.html
new file mode 100644
index 0000000..f615ae0
--- /dev/null
+++ b/builds/2.3.26-nightly/ref_builtins_node.html
@@ -0,0 +1,287 @@
+<!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>Built-ins for nodes (for XML) - Apache 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="Apache FreeMarker Manual">
+<meta property="og:title" content="Built-ins for nodes (for XML)">
+<meta property="og:locale" content="en_US">
+<meta property="og:url" content="http://freemarker.org/docs/ref_builtins_node.html">
+<link rel="canonical" href="http://freemarker.org/docs/ref_builtins_node.html">
+<link rel="icon" href="favicon.png" type="image/png">
+<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono">
+<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979">
+<script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ga('create', 'UA-55420501-1', 'auto');
+ga('send', 'pageview');
+</script>
+</head>
+<body itemscope itemtype="https://schema.org/Code">
+ <meta itemprop="url" content="http://freemarker.org/docs/">
+ <meta itemprop="name" content="Apache 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://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker">
+</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc
h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></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">Apache 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">Template Language Reference</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_builtins.html"><span itemprop="name">Built-in Reference</span></a></li><li class="step-3"
itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_builtins_node.html"><span itemprop="name">Built-ins for nodes (for XML)</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width">
+ <div class="content-wrapper">
+ <div id="table-of-contents-wrapper" class="col-left">
+ <script>var breadcrumb = ["Apache FreeMarker Manual","Template Language Reference","Built-in Reference","Built-ins for nodes (for XML)"];</script>
+ <script src="toc.js?1489402528979"></script>
+ <script src="docgen-resources/main.min.js?1489402528979"></script>
+ </div>
+<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="ref_builtins_hash.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_builtins_loop_var.html"><span>Next</span></a></div><div class="title-wrapper">
+<h1 class="content-header header-section1" id="ref_builtins_node" itemprop="headline">Built-ins for nodes (for XML)</h1>
+</div></div><div class="page-menu">
+<div class="page-menu-title">Page Contents</div>
+<ul><li><a class="page-menu-link" href="#ref_builtin_ancestors" data-menu-target="ref_builtin_ancestors">ancestors</a></li><li><a class="page-menu-link" href="#ref_builtin_children" data-menu-target="ref_builtin_children">children</a></li><li><a class="page-menu-link" href="#ref_builtin_node_name" data-menu-target="ref_builtin_node_name">node_name</a></li><li><a class="page-menu-link" href="#ref_builtin_next_sibling" data-menu-target="ref_builtin_next_sibling">next_sibling</a></li><li><a class="page-menu-link" href="#ref_builtin_node_namespace" data-menu-target="ref_builtin_node_namespace">node_namespace</a></li><li><a class="page-menu-link" href="#ref_builtin_node_type" data-menu-target="ref_builtin_node_type">node_type</a></li><li><a class="page-menu-link" href="#ref_builtin_parent" data-menu-target="ref_builtin_parent">parent</a></li><li><a class="page-menu-link" href="#ref_builtin_previous_sibling" data-menu-target="ref_builtin_previous_sibling">previous_sibling</a></li><li><a c
lass="page-menu-link" href="#ref_builtin_root" data-menu-target="ref_builtin_root">root</a></li></ul> </div><p>Note that the variables returned by these built-ins are
+ generated by the node variable implementation it is used with. This
+ means that the returned variables can have extra features in
+ additional to what it stated here, for example, with the <a href="xgui_expose_dom.html">XML DOM nodes</a> the sequence retuned by
+ the <code class="inline-code">children</code> built-in also can be used as hash and
+ maybe as string, as it is described in the <a href="xgui.html">part
+ about XML processing</a>.</p>
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_ancestors">ancestors</h2>
+
+
+
+
+ <p>A sequence that contains all the node's ancestors, starting
+ with the immediate parent and ending with the root node. The result
+ of this built-in is also a method, by which you can filter the
+ result with the <a href="gloss.html#gloss.fullQualifiedName">full-qualified name</a> of the
+ node. For example as <code class="inline-code">node?ancestors("section")</code> to
+ get the sequence of all ancestors with name
+ <code class="inline-code">section</code>.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_children">children</h2>
+
+
+
+
+ <p>A sequence that contains all of this node's child nodes (i.e.
+ immediate descendant nodes).</p>
+
+ <p>XML: This is almost the same as special hash key
+ <code class="inline-code">*</code>, except that it returns all nodes, not only
+ elements. So the possible children are element nodes, text nodes,
+ comment nodes, processing instruction nodes, etc. but
+ <em>not</em> attribute nodes. Attribute nodes are
+ excluded from the sequence.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_node_name">node_name</h2>
+
+
+
+
+ <p>Returns the string that is used to determine what user-defined
+ directive to invoke to handle this node when it is
+ "visited". See: the <a href="ref_directive_visit.html#ref.directive.visit">visit</a> and <a href="ref_directive_visit.html#ref.directive.recurse">recurse</a> directives.</p>
+
+ <p>XML: If the node is an element or attribute, then the string
+ will be the local (prefix free) name of the element or attribute.
+ Otherwise the name usually starts with <code class="inline-code">@</code> followed
+ by the node type. See <a href="xgui_imperative_formal.html#misc.xguiTable">this
+ table</a>. Note that this node name is not the same as the node
+ name returned in the DOM API; the goal of FreeMarker node names is
+ to give the name of the used-defined directive that will process the
+ node.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_next_sibling">next_sibling</h2>
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in is only available since 2.3.26</p>
+ </div>
+
+
+ <p>Returns the following sibling node of the node. (Two nodes in
+ a tree are said to be siblings if they are on the same level and are
+ directly next to each other.) If there's no such node, the
+ expression
+ <code class="inline-code"><em class="code-color">node</em>?next_sibling??</code>
+ evaluates to <code class="inline-code">false</code>.</p>
+
+ <p>XML: Note that the value returned by this built-in is also a
+ sequence of length 1 (same as the result of some XPath expressions),
+ however if there's no next sibling, the result is a missing value
+ (null) instead of an empty sequence. Also note that for XML element
+ nodes you can also use
+ <code class="inline-code"><em class="code-color">node</em>.@@next_sibling_element</code>,
+ which is practical if you want to ignore the whitespace that
+ separates two apparently sibling elements; see more <a href="xgui_imperative_formal.html">here...</a></p>
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>For custom node implementations this built-in is only
+ supported if that implements the
+ <code class="inline-code">freemarker.template.TemplateNodeModelEx</code>
+ interface.</p>
+ </div>
+
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_node_namespace">node_namespace</h2>
+
+
+
+
+ <p>Returns the namespace string of the node. FreeMarker does not
+ define the exact meaning of node namespace; it depends on what your
+ node variables are modeling. It's possible that a node doesn't have
+ any node namespace defined. In this case, the built-in should
+ evaluate to undefined variable (i.e.
+ <code class="inline-code">node?<em class="code-color">node_namespace</em>??</code>
+ is <code class="inline-code">false</code>), so you can't use the returned
+ value.</p>
+
+ <p>XML: In the case of XML, it's the XML namespace URI (such as
+ <code class="inline-code">"http://www.w3.org/1999/xhtml"</code>). If an element or
+ attribute node does not use XML namespace, then this built-in
+ evaluates to an empty string. For other XML nodes this built-in
+ always return undefined variable.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_node_type">node_type</h2>
+
+
+
+
+ <p>A string that describes the type of the node. FreeMarker does
+ not define the exact meaning of node type; it depends on what your
+ variables are modeling. It's possible that a node doesn't support
+ node type at all. In this case, the built-in evaluates to an
+ undefined value, so you can't use the returned value. (You can still
+ check if a node supports the type property with
+ <code class="inline-code"><em class="code-color">node</em>?node_type??</code>.)</p>
+
+ <p>XML: The possible values are: <code class="inline-code">"attribute"</code>,
+ <code class="inline-code">"text"</code>, <code class="inline-code">"comment"</code>,
+ <code class="inline-code">"document_fragment"</code>,
+ <code class="inline-code">"document"</code>, <code class="inline-code">"document_type"</code>,
+ <code class="inline-code">"element"</code>, <code class="inline-code">"entity"</code>,
+ <code class="inline-code">"entity_reference"</code>,
+ <code class="inline-code">"notation"</code>, <code class="inline-code">"pi"</code>. Note that a
+ there is no <code class="inline-code">"cdata"</code> type, because CDATA is
+ considered as plain text node.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_parent">parent</h2>
+
+
+
+
+ <p>Returns the node that is this node's immediate parent in the
+ node tree. The root node has no parent node, so for the root node,
+ the expression
+ <code class="inline-code"><em class="code-color">node</em>?parent??</code>
+ evaluates to <code class="inline-code">false</code>.</p>
+
+ <p>XML: Note that the value returned by this built-in is also a
+ sequence (same as the result of XPath expression
+ <code class="inline-code">..</code>, when you write
+ <code class="inline-code">someNode[".."]</code>), however if there's no parent,
+ the result is a missing value (null) instead of an empty sequence.
+ Also note that for attribute nodes, it returns the element the
+ attribute belongs to, despite that attribute nodes are not counted
+ as children of the element.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_previous_sibling">previous_sibling</h2>
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in is only available since 2.3.26</p>
+ </div>
+
+
+ <p>Returns the previous sibling node of the node. Apart from the
+ direction, this is the same as <code class="inline-code">next_sibling</code>, so
+ see more details <a href="#ref_builtin_next_sibling">there...</a></p>
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>For custom node implementations this built-in is only
+ supported if that implements the
+ <code class="inline-code">freemarker.template.TemplateNodeModelEx</code>
+ interface.</p>
+ </div>
+
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_root">root</h2>
+
+
+
+
+ <p>The node that is the root of the tree of nodes to which this
+ node belongs.</p>
+
+ <p>XML: According to W3C, the root of an XML document is not the
+ topmost element node, but the document itself, which is the parent
+ of the topmost element. For example, if you want to get the topmost
+ <em>element</em> of the XML (the so called
+ "document element"; do not mix it with the
+ "document"), which is called <code class="inline-code">foo</code>,
+ then you have to write <code class="inline-code">someNode?root.foo</code>. If you
+ write just <code class="inline-code">someNode?root</code>, then you get the
+ document itself, and not the document element.</p>
+ <div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="ref_builtins_hash.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_builtins_loop_var.html"><span>Next</span></a></div></div></div></div> </div>
+ </div>
+<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href
="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated">
+Last generated:
+<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p>
+<p class="copyright">
+� <span itemprop="copyrightYear">1999</span>\u20132017
+<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p>
+</div></div></div></body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/52c070a9/builds/2.3.26-nightly/ref_builtins_number.html
----------------------------------------------------------------------
diff --git a/builds/2.3.26-nightly/ref_builtins_number.html b/builds/2.3.26-nightly/ref_builtins_number.html
new file mode 100644
index 0000000..4c99464
--- /dev/null
+++ b/builds/2.3.26-nightly/ref_builtins_number.html
@@ -0,0 +1,797 @@
+<!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>Built-ins for numbers - Apache 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="Apache FreeMarker Manual">
+<meta property="og:title" content="Built-ins for numbers">
+<meta property="og:locale" content="en_US">
+<meta property="og:url" content="http://freemarker.org/docs/ref_builtins_number.html">
+<link rel="canonical" href="http://freemarker.org/docs/ref_builtins_number.html">
+<link rel="icon" href="favicon.png" type="image/png">
+<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono">
+<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979">
+<script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ga('create', 'UA-55420501-1', 'auto');
+ga('send', 'pageview');
+</script>
+</head>
+<body itemscope itemtype="https://schema.org/Code">
+ <meta itemprop="url" content="http://freemarker.org/docs/">
+ <meta itemprop="name" content="Apache 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://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker">
+</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc
h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></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">Apache 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">Template Language Reference</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_builtins.html"><span itemprop="name">Built-in Reference</span></a></li><li class="step-3"
itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_builtins_number.html"><span itemprop="name">Built-ins for numbers</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width">
+ <div class="content-wrapper">
+ <div id="table-of-contents-wrapper" class="col-left">
+ <script>var breadcrumb = ["Apache FreeMarker Manual","Template Language Reference","Built-in Reference","Built-ins for numbers"];</script>
+ <script src="toc.js?1489402528979"></script>
+ <script src="docgen-resources/main.min.js?1489402528979"></script>
+ </div>
+<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="ref_builtins_string.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_builtins_date.html"><span>Next</span></a></div><div class="title-wrapper">
+<h1 class="content-header header-section1" id="ref_builtins_number" itemprop="headline">Built-ins for numbers</h1>
+</div></div><div class="page-menu">
+<div class="page-menu-title">Page Contents</div>
+<ul><li><a class="page-menu-link" href="#ref_builtin_abs" data-menu-target="ref_builtin_abs">abs</a></li><li><a class="page-menu-link" href="#ref_builtin_c" data-menu-target="ref_builtin_c">c (when used with numerical value)</a></li><li><a class="page-menu-link" href="#ref_builtin_is_infinite" data-menu-target="ref_builtin_is_infinite">is_infinite</a></li><li><a class="page-menu-link" href="#ref_builtin_is_nan" data-menu-target="ref_builtin_is_nan">is_nan</a></li><li><a class="page-menu-link" href="#ref_builtin_lower_abc" data-menu-target="ref_builtin_lower_abc">lower_abc</a></li><li><a class="page-menu-link" href="#ref_builtin_rounding" data-menu-target="ref_builtin_rounding">round, floor, ceiling</a></li><li><a class="page-menu-link" href="#ref_builtin_string_for_number" data-menu-target="ref_builtin_string_for_number">string (when used with a numerical value)</a></li><li><a class="page-menu-link" href="#ref_builtin_upper_abc" data-menu-target="ref_builtin_upper_abc">upper_abc</a>
</li></ul> </div><p>Related FAQs: Do you have things like 1,000,000 or 1�000�000
+ instead of 1000000, or something like 3.14 instead of 3,14 or vice
+ versa? See <a href="app_faq.html#faq_number_grouping">this</a> and <a href="app_faq.html#faq_number_decimal_point">this</a> FAQ entry, also note
+ the <code class="inline-code">c</code> built-in above.</p>
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_abs">abs</h2>
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.20.</p>
+ </div>
+
+
+ <p>Gives the absolute value of a number. For example
+ <code class="inline-code">x?abs</code> , if <code class="inline-code">x</code> is -5, will
+ evaluate to 5.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_c">c (when used with numerical value)</h2>
+
+
+
+
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.3.</p>
+ </div>
+
+
+ <p>This built-in converts a number to string for a
+ "computer language" as opposed to for human audience.
+ That is, it formats with the rules that programming languages used
+ to use, which is independent of all the locale and number format
+ settings of FreeMarker. It always uses dot as decimal separator, and
+ it never uses grouping separators (like 3,000,000), nor exponential
+ form (like 5E20), nor superfluous leading or trailing 0-s (like 03
+ or 1.0), nor + sign (like +1). It will print at most 16 digits after
+ the decimal dot, and thus numbers whose absolute value is less than
+ 1E-16 will be shown as 0. This built-in is crucial because be
+ default (like with <code class="inline-code">${x}</code>) numbers are converted to
+ strings with the locale (language, country) specific number
+ formatting, which is for human readers (like 3000000 is possibly
+ printed as 3,000,000). When the number is printed not for human
+ audience (e.g., for a database record ID used as the part of an URL,
+ or as invisible field value in a HTML form, or for printing
+ CSS/JavaScript numerical literals) this built-in must be used to
+ print the number (i.e., use <code class="inline-code">${x?c}</code> instead of
+ <code class="inline-code">${x}</code>), or else the output will be possibly broken
+ depending on the current number formatting settings and locale (like
+ the decimal point is not dot, but comma in many countries) and the
+ value of the number (like big numbers are possibly
+ "damaged" by grouping separators).</p>
+
+ <p>If the <code class="inline-code">incompatible_imporvements</code> FreeMarker
+ configuration setting is set to 2.3.24 or higher (also if it's set
+ to 2.3.20 or higher and you are outside a string literal), this
+ built-in will return <code class="inline-code">"INF"</code>,
+ <code class="inline-code">"-INF"</code> and <code class="inline-code">"NaN"</code> for
+ positive/negative infinity and IEEE floating point Not-a-Number,
+ respectively. These are the XML Schema compatible representations of
+ these special values. (Earlier it has returned what
+ <code class="inline-code">java.text.DecimalFormat</code> did with US locale, none
+ of which is understood by any (common) computer language.)</p>
+
+ <p>Note that this built-in <a href="ref_builtins_boolean.html#ref_builtin_c_boolean">also works on
+ booleans</a>.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_is_infinite">is_infinite</h2>
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.20.</p>
+ </div>
+
+
+ <p>Tells if a number is floating point infinite (according to
+ IEEE 754). For example, <code class="inline-code">someNumber?is_infinite</code>
+ evaluates to <code class="inline-code">true</code> or <code class="inline-code">false</code>
+ depending on if the value of <code class="inline-code">someNumber</code> is
+ infinite or not. Of course, if the underlying number is not of
+ floating point type, this will always return
+ <code class="inline-code">false</code>.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_is_nan">is_nan</h2>
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.20.</p>
+ </div>
+
+
+ <p>Tells if a number is floating point NaN (according to IEEE
+ 754). For example, <code class="inline-code">someNumber?is_nan</code> evaluates to
+ <code class="inline-code">true</code> or <code class="inline-code">false</code> depending on if
+ the value of <code class="inline-code">someNumber</code> is NaN or not. Of course,
+ if the underlying number is not of floating point type, this will
+ always return <code class="inline-code">false</code>.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_lower_abc">lower_abc</h2>
+
+
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.22.</p>
+ </div>
+
+
+ <p>Converts <code class="inline-code">1</code>, <code class="inline-code">2</code>,
+ <code class="inline-code">3</code>, etc., to the string <code class="inline-code">"a"</code>,
+ <code class="inline-code">"b"</code>, <code class="inline-code">"c"</code>, etc. When reaching
+ <code class="inline-code">"z"</code>, it continues like <code class="inline-code">"aa"</code>,
+ <code class="inline-code">"ab"</code>, etc. This is the same logic that you can
+ see in column labels in spreadsheet applications (like Excel or
+ Calc). The lowest allowed number is <code class="inline-code">1</code>. There's no
+ upper limit. If the number is <code class="inline-code">0</code> or less or it
+ isn't an integer number then the template processing will be aborted
+ with error.</p>
+
+ <p>Example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#list 1..30 as n>${n?lower_abc} </#list></pre></div>
+
+ <p>Prints:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad </pre></div>
+
+ <p>See also: <a href="#ref_builtin_upper_abc"><code>upper_abc</code></a></p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_rounding">round, floor, ceiling</h2>
+
+
+
+
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>The rounding built-ins exist since FreeMarker 2.3.13.</p>
+ </div>
+
+
+ <p>Converts a number to a whole number using the specified
+ rounding rule:</p>
+
+ <ul>
+ <li>
+ <p><code class="inline-code">round</code>: Rounds to the nearest whole
+ number. If the number ends with .5, then it rounds upwards
+ (i.e., towards positive infinity)</p>
+ </li>
+
+ <li>
+ <p><code class="inline-code">floor</code>: Rounds the number downwards
+ (i.e., towards neagative infinity)</p>
+ </li>
+
+ <li>
+ <p><code class="inline-code">ceiling</code>: Rounds the number upwards
+ (i.e., towards positive infinity)</p>
+ </li>
+ </ul>
+
+ <p>Example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign testlist=[
+ 0, 1, -1, 0.5, 1.5, -0.5,
+ -1.5, 0.25, -0.25, 1.75, -1.75]>
+<#list testlist as result>
+ ${result} ?floor=${result?floor} ?ceiling=${result?ceiling} ?round=${result?round}
+</#list></pre></div>
+
+ <p>Prints:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output"> 0 ?floor=0 ?ceiling=0 ?round=0
+ 1 ?floor=1 ?ceiling=1 ?round=1
+ -1 ?floor=-1 ?ceiling=-1 ?round=-1
+ 0.5 ?floor=0 ?ceiling=1 ?round=1
+ 1.5 ?floor=1 ?ceiling=2 ?round=2
+ -0.5 ?floor=-1 ?ceiling=0 ?round=0
+ -1.5 ?floor=-2 ?ceiling=-1 ?round=-1
+ 0.25 ?floor=0 ?ceiling=1 ?round=0
+ -0.25 ?floor=-1 ?ceiling=0 ?round=0
+ 1.75 ?floor=1 ?ceiling=2 ?round=2
+ -1.75 ?floor=-2 ?ceiling=-1 ?round=-2</pre></div>
+
+ <p>These built-ins may be useful in pagination operations and
+ like. If you just want to <em>display</em> numbers in
+ rounded form, then you should rather use the <a href="#ref_builtin_string_for_number"><code>string</code>
+ built-in</a> or the <a href="ref_directive_setting.html#ref.setting.number_format"><code>number_format</code>
+ setting</a>.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_string_for_number">string (when used with a numerical value)</h2>
+
+
+
+
+
+
+
+
+
+
+ <p>Converts a number to a string. In its simplest form
+ (<code class="inline-code"><em class="code-color">expression</em>?string</code>) it
+ uses the default format that the programmer has specified via the
+ <code class="inline-code">number_format</code> and the <code class="inline-code">locale</code>
+ configuration settings. You can also specify a number format
+ explicitly with this built-in, as it will be shown later.</p>
+
+ <p>There are four predefined number formats:
+ <code class="inline-code">computer</code>, <code class="inline-code">currency</code>,
+ <code class="inline-code">number</code>, and <code class="inline-code">percent</code>. The exact
+ meaning of these is locale (nationality) specific, and is controlled
+ by the Java platform installation, not by FreeMarker, except for
+ <code class="inline-code">computer</code>, which uses the same formatting as <a href="#ref_builtin_c">the <code>c</code> built-in</a>.
+ There can also be programmer-defined formats, whose name starts with
+ <code class="inline-code">@</code> (programmers <a href="pgui_config_custom_formats.html">see more here...</a>). You
+ can use these predefined formats like this:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign x=42>
+${x}
+${x?string} <#-- the same as ${x} -->
+${x?string.number}
+${x?string.currency}
+${x?string.percent}
+${x?string.computer}</pre></div>
+
+ <p>If your locale is US English, this will print:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">42
+42
+42
+$42.00
+4,200%
+42</pre></div>
+
+ <p>The output of first three expressions is identical because the
+ first two expressions use the default format, which is
+ "number" here. You can change this default using a
+ setting:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#setting number_format="currency">
+<#assign x=42>
+${x}
+${x?string} <#-- the same as ${x} -->
+${x?string.number}
+${x?string.currency}
+${x?string.percent}</pre></div>
+
+ <p>Will now output:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">$42.00
+$42.00
+42
+$42.00
+4,200%</pre></div>
+
+ <p>since the default number format was set to
+ "currency".</p>
+
+ <p>You can also refer to named custom formats that were defined
+ when configuring FreeMarker (programmers <a href="pgui_config_custom_formats.html">see more here</a>),
+ like:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template">${x?string.@price}
+${x?string.@weight}</pre></div>
+
+ <p>where the custom format names were "price" and
+ "weight". This way the templates can just refer to the
+ application-domain meaning, and the exact format can be specified
+ outside the templates, on a single central place. (Programmers can
+ read about <a href="pgui_config_custom_formats.html">defining such
+ named formats here...</a>)</p>
+
+ <p>Beside named formats, you can specify number format patterns
+ directly, using the <a href="http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html">Java
+ decimal number format syntax</a> (with some FreeMarker-specific
+ extensions; <a href="#topic.extendedJavaDecimalFormat">see
+ later</a>):</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign x = 1.234>
+${x?string["0"]}
+${x?string["0.#"]}
+${x?string["0.##"]}
+${x?string["0.###"]}
+${x?string["0.####"]}
+
+${1?string["000.00"]}
+${12.1?string["000.00"]}
+${123.456?string["000.00"]}
+
+${1.2?string["0"]}
+${1.8?string["0"]}
+${1.5?string["0"]} <-- 1.5, rounded towards even neighbor
+${2.5?string["0"]} <-- 2.5, rounded towards even neighbor
+
+${12345?string["0.##E0"]}</pre></div>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">1
+1.2
+1.23
+1.234
+1.234
+
+001.00
+012.10
+123.46
+
+1
+2
+2 <-- 1.5, rounded towards even neighbor
+2 <-- 2.5, rounded towards even neighbor
+
+1.23E4</pre></div>
+
+ <p>Note that as in FreeMarker <code class="inline-code">foo.bar</code> is
+ equivalent with <code class="inline-code">foo["bar"]</code>, you could also write
+ <code class="inline-code">x?string.currency</code> as
+ <code class="inline-code">x?string["currency"]</code>, but of course that wouldn't
+ be practical. But in the above examples we have to use the square
+ bracket syntax, because the characters involved (numbers, dot,
+ <code class="inline-code">#</code>) aren't allowed syntactically after the dot
+ operator.</p>
+
+ <p>For historical reasons, you could also write things like
+ <code class="inline-code">x?string("0.#")</code>, which does exactly the same as
+ <code class="inline-code">x?string["0.#"]</code>.</p>
+
+ <p>Following the financial and statistics practice, by default
+ the rounding goes according the so called half-even rule, which
+ means rounding towards the nearest "neighbor", unless
+ both neighbors are equidistant, in which case, it rounds towards the
+ even neighbor. This was visible in the above example if you look at
+ the rounding of 1.5 and of 2.5, as both were rounded to 2, since 2
+ is even, but 1 and 3 are odds. The other popular rounding rule,
+ where we always round up when the neighbors are equidistant (and so
+ 2.5 is rounded to 3) is called the half-up rule, and it can be
+ activated as <a href="#topic.extendedJavaDecimalFormat">described
+ later</a>.</p>
+
+ <p>As it was shown for the predefined formats earlier, the
+ default formatting of the numbers can be set in the template:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#setting number_format="0.##">
+${1.234}</pre></div>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">1.23</pre></div>
+
+ <p>The default number format also can be specified outside the
+ templates with the FreeMarker API (like with
+ <code class="inline-code">Configuration.setNumberFormat(String)</code>).</p>
+
+ <p>Note that as number formatting is locale sensitive, the locale
+ setting also plays role in the formatting:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#setting number_format=",##0.00">
+<#setting locale="en_US">
+US people write: ${12345678}
+<#setting locale="hu">
+German people write: ${12345678}</pre></div>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">US people write: 12,345,678.00
+German people write: 12.345.678,00</pre></div>
+
+
+
+
+
+
+<h3 class="content-header header-simplesect" id="topic.extendedJavaDecimalFormat">Extended Java decimal format</h3>
+
+
+
+
+ <p>FreeMarker extends the Java decimal format patterns with
+ extra options. These options are name-value pairs, specified after
+ two semicolons (<code class="inline-code">;;</code>) at the end of the format
+ string, or if you had a negative pattern (which is separated from
+ the normal patter with a semicolon, like in <code class="inline-code">"0.0;minus
+ 0.0"</code>), the after only one semicolon. For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template">Standard decimal format: ${10002.5?string[",000"]}
+Extended decimal format: ${10002.5?string[",000<strong>;; roundingMode=halfUp groupingSeparator=_</strong>"]}</pre></div>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">Standard decimal format: 10,002
+Extended decimal format: 10<strong>_</strong>00<strong>3</strong></pre></div>
+
+ <p>Above, in the extended decimal format, we have specified
+ half-up rounding mode and group separator <code class="inline-code">"_"</code>.
+ The table of all options follows (note that these are defined by
+ <code class="inline-code">java.text.DecimalFormat</code> and
+ <code class="inline-code">java.text.DecimalFormatSymbols</code>, not by
+ FreeMarker):</p>
+
+ <div class="table-responsive">
+ <table class="table">
+
+ <thead>
+ <tr>
+ <th>Name</th>
+
+
+ <th>Meaning / value</th>
+
+ </tr>
+
+ </thead>
+
+
+ <tbody>
+ <tr>
+ <td><code class="inline-code">roundingMode</code></td>
+
+
+ <td>The value is one of <code class="inline-code">up</code>,
+ <code class="inline-code">down</code>, <code class="inline-code">ceiling</code>,
+ <code class="inline-code">floor</code>, <code class="inline-code">halfUp</code>,
+ <code class="inline-code">halfDown</code>, <code class="inline-code">halfEven</code>,
+ and <code class="inline-code">unnecessary</code>. The behavior that most
+ people learns in school is <code class="inline-code">halfUp</code>, but
+ the Java default is <code class="inline-code">halfEven</code> (also called
+ bankers' rounding). (See <a href="http://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html">the
+ <code>java.math.RoundingMode</code> API</a> for
+ explanations.)</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">multipier</code></td>
+
+
+ <td>The number will be shown after multiplied with this
+ integer number.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">decimalSeparator</code></td>
+
+
+ <td>The character separating the integer part from the
+ fraction part (like <code class="inline-code">"."</code> in
+ <code class="inline-code">3.14</code>).</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">monetaryDecimalSeparator</code></td>
+
+
+ <td>This is used instead of
+ <code class="inline-code">decimalSeparator</code> when the pattern
+ contains parts that make it a monetary format. (See the
+ <a href="http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html">Java
+ decimal number format documentation</a> for more.)</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">groupingSeparator</code></td>
+
+
+ <td>The single character used for grouping the integer part
+ (like <code class="inline-code">","</code> in
+ <code class="inline-code">1,000,000</code>) Note that grouping is turned
+ on by using <code class="inline-code">","</code> in the pattern, as shown
+ in the earlier example. If it's not turned on, this option
+ won't have visible effect.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">exponentSeparator</code></td>
+
+
+ <td>This string (of arbitrary length) is used to separate
+ the exponent from the part before it. (like
+ <code class="inline-code">"E"</code> in <code class="inline-code">1.23E6</code>). Only
+ has visible effect if the pattern specifies exponential
+ (also known as scientific) format, like
+ <code class="inline-code">"0.##E0"</code>.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">minusSign</code></td>
+
+
+ <td>The single character used as minus sign (like
+ <code class="inline-code">"-"</code> in <code class="inline-code">-1</code>).</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">infinity</code></td>
+
+
+ <td>The string (of arbitrary length) used to show
+ infinity.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">nan</code></td>
+
+
+ <td>The string (of arbitrary length) used to show
+ not-a-number (NaN).</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">percent</code></td>
+
+
+ <td>The single character used as the percent symbol (like
+ <code class="inline-code">"%"</code> in <code class="inline-code">50%</code>). Only has
+ visible effect if the pattern contains
+ <code class="inline-code">%</code>.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">perMill</code></td>
+
+
+ <td>The single character used as the per-mill symbol (like
+ <code class="inline-code">"\u2030"</code> in <code class="inline-code">50021\u2030</code>). Only
+ has visible effect if the pattern contains
+ <code class="inline-code">\u2030</code>.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">zeroDigit</code></td>
+
+
+ <td>The first character in the 10 character range (of
+ character codes) that contains the digits to be used. For
+ example, if this is <code class="inline-code">A</code>, then 1 will
+ <code class="inline-code">B</code>, 2 will be <code class="inline-code">C</code>, and so
+ on.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">currencyCode</code></td>
+
+
+ <td>Currency ISO 4217 code. Only has effect when the pattern
+ contains parts that make it a monetary format. It's an error
+ to specify a code that's not a known ISO 4217 code in the
+ Java installation.</td>
+
+ </tr>
+
+
+ <tr>
+ <td><code class="inline-code">currencySymbol</code></td>
+
+
+ <td>Currency symbol; shown where the localized currency name
+ is present in the pattern. Overrides the symbol determined
+ based on the <code class="inline-code">currencyCode</code>.</td>
+
+ </tr>
+
+ </tbody>
+
+ </table>
+ </div>
+
+
+ <p>Regarding the syntax of the options:</p>
+
+ <ul>
+ <li>
+ <p>The option name and value are separated by equals
+ character (<code class="inline-code">=</code>).</p>
+ </li>
+
+ <li>
+ <p>Options are separated by whitespace and/or optional
+ comma (<code class="inline-code">,</code>)</p>
+ </li>
+
+ <li>
+ <p>The option value can be quoted with apostrophe
+ (<code class="inline-code">'</code>) or normal quotation mark
+ (<code class="inline-code">"</code>) , like
+ <code class="inline-code">exponentSeparator='*10^'</code> or
+ <code class="inline-code">exponentSeparator="*10^"</code>. If the value
+ itself has to contain the character used for quotation, then
+ it has to be entered twice (like <code class="inline-code">infinity='It''s
+ infinite'</code>, but you could also write
+ <code class="inline-code">infinity="It's infinite"</code>). Backslash has no
+ special meaning.</p>
+ </li>
+
+ <li>
+ <p>Non-string values must not be quoted. Strings only has
+ to be quoted if they contain punctuation or whitespace, or any
+ other non-letter non-digit non-<code class="inline-code">"_"</code>
+ non-<code class="inline-code">"$"</code> characters. Thus, for example, both
+ <code class="inline-code">roundingMode=down</code> and
+ <code class="inline-code">roundingMode="down"</code> are legal.</p>
+ </li>
+ </ul>
+
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_upper_abc">upper_abc</h2>
+
+
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.22.</p>
+ </div>
+
+
+ <p>Same as <a href="#ref_builtin_lower_abc"><code>lower_abc</code></a>,
+ but converts to upper case letters, like <code class="inline-code">"A"</code>,
+ <code class="inline-code">"B"</code>, <code class="inline-code">"C"</code>, \u2026,
+ <code class="inline-code">"AA"</code>, <code class="inline-code">"AB"</code>, etc.</p>
+ <div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="ref_builtins_string.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_builtins_date.html"><span>Next</span></a></div></div></div></div> </div>
+ </div>
+<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href
="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated">
+Last generated:
+<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p>
+<p class="copyright">
+� <span itemprop="copyrightYear">1999</span>\u20132017
+<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p>
+</div></div></div></body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker-site/blob/52c070a9/builds/2.3.26-nightly/ref_builtins_sequence.html
----------------------------------------------------------------------
diff --git a/builds/2.3.26-nightly/ref_builtins_sequence.html b/builds/2.3.26-nightly/ref_builtins_sequence.html
new file mode 100644
index 0000000..a3fe4ba
--- /dev/null
+++ b/builds/2.3.26-nightly/ref_builtins_sequence.html
@@ -0,0 +1,577 @@
+<!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>Built-ins for sequences - Apache 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="Apache FreeMarker Manual">
+<meta property="og:title" content="Built-ins for sequences">
+<meta property="og:locale" content="en_US">
+<meta property="og:url" content="http://freemarker.org/docs/ref_builtins_sequence.html">
+<link rel="canonical" href="http://freemarker.org/docs/ref_builtins_sequence.html">
+<link rel="icon" href="favicon.png" type="image/png">
+<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono">
+<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1489402528979">
+<script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ga('create', 'UA-55420501-1', 'auto');
+ga('send', 'pageview');
+</script>
+</head>
+<body itemscope itemtype="https://schema.org/Code">
+ <meta itemprop="url" content="http://freemarker.org/docs/">
+ <meta itemprop="name" content="Apache 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://freemarker.org" role="banner"> <img itemprop="image" src="logo.png" alt="FreeMarker">
+</a><ul class="tabs"><li><a href="http://freemarker.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="http://freemarker.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/browse/FREEMARKER/" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="http://freemarker.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="searc
h-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></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">Apache 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">Template Language Reference</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_builtins.html"><span itemprop="name">Built-in Reference</span></a></li><li class="step-3"
itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_builtins_sequence.html"><span itemprop="name">Built-ins for sequences</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width">
+ <div class="content-wrapper">
+ <div id="table-of-contents-wrapper" class="col-left">
+ <script>var breadcrumb = ["Apache FreeMarker Manual","Template Language Reference","Built-in Reference","Built-ins for sequences"];</script>
+ <script src="toc.js?1489402528979"></script>
+ <script src="docgen-resources/main.min.js?1489402528979"></script>
+ </div>
+<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="ref_builtins_boolean.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_builtins_hash.html"><span>Next</span></a></div><div class="title-wrapper">
+<h1 class="content-header header-section1" id="ref_builtins_sequence" itemprop="headline">Built-ins for sequences</h1>
+</div></div><div class="page-menu">
+<div class="page-menu-title">Page Contents</div>
+<ul><li><a class="page-menu-link" href="#ref_builtin_chunk" data-menu-target="ref_builtin_chunk">chunk</a></li><li><a class="page-menu-link" href="#ref_builtin_first" data-menu-target="ref_builtin_first">first</a></li><li><a class="page-menu-link" href="#ref_builtin_join" data-menu-target="ref_builtin_join">join</a></li><li><a class="page-menu-link" href="#ref_builtin_last" data-menu-target="ref_builtin_last">last</a></li><li><a class="page-menu-link" href="#ref_builtin_reverse" data-menu-target="ref_builtin_reverse">reverse</a></li><li><a class="page-menu-link" href="#ref_builtin_seq_contains" data-menu-target="ref_builtin_seq_contains">seq_contains</a></li><li><a class="page-menu-link" href="#ref_builtin_seq_index_of" data-menu-target="ref_builtin_seq_index_of">seq_index_of</a></li><li><a class="page-menu-link" href="#ref_builtin_seq_last_index_of" data-menu-target="ref_builtin_seq_last_index_of">seq_last_index_of</a></li><li><a class="page-menu-link" href="#ref_builtin_size" data
-menu-target="ref_builtin_size">size</a></li><li><a class="page-menu-link" href="#ref_builtin_sort" data-menu-target="ref_builtin_sort">sort</a></li><li><a class="page-menu-link" href="#ref_builtin_sort_by" data-menu-target="ref_builtin_sort_by">sort_by</a></li></ul> </div>
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_chunk">chunk</h2>
+
+
+
+
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in exists since FreeMarker 2.3.3.</p>
+ </div>
+
+
+ <p>This built-in splits a sequence into multiple sequences of the
+ size given with the 1st parameter to the built-in (like
+ <code class="inline-code">mySeq?chunk(3)</code>). The result is the sequence of
+ these sequences. The last sequence is possibly shorter than the
+ given size, unless the 2nd parameter is given (like
+ <code class="inline-code">mySeq?chunk(3, '-')</code>), that is the item used to
+ make up the size of the last sequence to the given size.
+ Example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign seq = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']>
+
+<#list seq?chunk(4) as row>
+ <#list row as cell>${cell} </#list>
+</#list>
+
+<#list seq?chunk(4, '-') as row>
+ <#list row as cell>${cell} </#list>
+</#list></pre></div>
+
+ <p>The output will be:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">
+ a b c d
+ e f g h
+ i j
+
+ a b c d
+ e f g h
+ i j - -
+ </pre></div>
+
+ <p>This built in is mostly for outputting sequnces in
+ tabular/columnar format. When used with HTML tables, the 2nd
+ parameter is often <code class="inline-code">"\xA0"</code> (that is the code of
+ the no-break space character, also known as "nbsp"), so
+ the border of the empty TD-s will not be missing.</p>
+
+ <p>The 1st parameter must be a number that is at least 1. If the
+ number is not integer, it will be silently rounded down to integer
+ (i.e. both 3.1 and 3.9 will be rounded to 3). The 2nd parameter can
+ be of any type and value.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_first">first</h2>
+
+
+
+
+ <p>Returns the first item of the sequence. Thus
+ <code class="inline-code"><em class="code-color">value</em>?first</code> is the
+ same as <code class="inline-code"><em class="code-color">value</em>[0]</code>,
+ except that, since FreeMarker 2.3.26,
+ <code class="inline-code"><em class="code-color">value</em>?first</code> also works
+ if <code class="inline-code"><em class="code-color">value</em></code> doesn't
+ support getting items with numerical index, but still supports to be
+ listed (i.e., with FTL collection values).</p>
+
+ <p>If the sequence or collection is empty, the result will be a
+ missing value (as in
+ <code class="inline-code"><em class="code-color">empty</em>?first!'No item was
+ found'</code>).</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_join">join</h2>
+
+
+
+
+ <p>Concatenates the items of a sequence to a single string, with
+ the given separator. For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign colors = ["red", "green", "blue"]>
+${colors?join(", ")}</pre></div>
+
+ <p>will output:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">red, green, blue</pre></div>
+
+ <p>Sequence items that are not strings will be converted to
+ string with the same conversion rules as of
+ <code class="inline-code">${<em class="code-color">...</em>}</code> (except, of
+ course, no automatic escaping is applied at this stage).</p>
+
+ <p><code class="inline-code">?join(<em class="code-color">...</em>)</code> can
+ have up to 3 parameters:</p>
+
+ <div class="orderedlist"><ol type="1">
+ <li>
+ <p>Separator, required: The string that is inserted between
+ items</p>
+ </li>
+
+ <li>
+ <p>Empty value, defaults to <code class="inline-code">""</code> (empty
+ string): The value used if the sequence contains no
+ items.</p>
+ </li>
+
+ <li>
+ <p>List ending, defaults to <code class="inline-code">""</code> (empty
+ string): The value printed after the last value, if the list
+ sequence wasn't empty.</p>
+ </li>
+ </ol></div>
+
+ <p>So this (where <code class="inline-code">[]</code> means an empty
+ sequence):</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template">${colors?join(", ", "-")}
+${[]?join(", ", "-")}
+
+${colors?join(", ", "-", ".")}
+${[]?join(", ", "-", ".")}</pre></div>
+
+ <p>will output:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">red, green, blue
+-
+
+red, green, blue.
+-</pre></div>
+
+ <p class="programmers-note">Sequences coming from Java might contain
+ <code class="inline-code">null</code> values. Those values will be ignored by this
+ built-in, exactly like if they were removed from the list.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_last">last</h2>
+
+
+
+
+ <p>The last subvariable of the sequence. Template processing will
+ die with error if the sequence is empty.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_reverse">reverse</h2>
+
+
+
+
+ <p>The sequence with reversed order.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_seq_contains">seq_contains</h2>
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in is available since FreeMarker 2.3.1. It
+ doesn't exist in 2.3.</p>
+ </div>
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>The <code class="inline-code">seq_</code> prefix is required in the
+ built-in name to differentiate it from the <a href="ref_builtins_string.html#ref_builtin_contains"><code>contains</code>
+ built-in</a> that searches a substring in a string (since a
+ variable can be both string and sequence on the same time).</p>
+ </div>
+
+
+ <p>Tells if the sequence contains the specified value. It has 1
+ parameter, the value to find. Example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign x = ["red", 16, "blue", "cyan"]>
+"blue": ${x?seq_contains("blue")?string("yes", "no")}
+"yellow": ${x?seq_contains("yellow")?string("yes", "no")}
+16: ${x?seq_contains(16)?string("yes", "no")}
+"16": ${x?seq_contains("16")?string("yes", "no")}</pre></div>
+
+ <p>The output will be:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">"blue": yes
+"yellow": no
+16: yes
+"16": no</pre></div>
+
+ <p>To find the value the built-in uses FreeMarker's comparison
+ rules (as if you was using <a href="dgui_template_exp.html#dgui_template_exp_comparison"><code>==</code>
+ operator</a>), except that comparing two values of different
+ types or of types for which FreeMarker doesn't support comparison
+ will not cause error, just will be evaluated as the two values are
+ not equal. Thus, you can use it only to find scalar values (i.e.
+ string, number, boolean or date/time values). For other types the
+ result will be always <code class="inline-code">false</code>.</p>
+
+ <p>For fault tolerance, this built-in also works with
+ collections.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_seq_index_of">seq_index_of</h2>
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in is available since FreeMarker 2.3.1. It
+ doesn't exist in 2.3.</p>
+ </div>
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>The <code class="inline-code">seq_</code> prefix is required in the
+ built-in name to differentiate it from the <a href="ref_builtins_string.html#ref_builtin_index_of"><code>index_of</code>
+ built-in</a> that searches a substring in a string (since a
+ variable can be both string and sequence on the same time).</p>
+ </div>
+
+
+ <p>Returns the index of the first occurrence of a value in the
+ sequence, or <code class="inline-code">-1</code> if the sequence doesn't contain
+ the specified value. The value to find is specified as the first
+ parameter. For example this template:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign colors = ["red", "green", "blue"]>
+${colors?seq_index_of("blue")}
+${colors?seq_index_of("red")}
+${colors?seq_index_of("purple")}</pre></div>
+
+ <p>will output this:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">2
+0
+-1</pre></div>
+
+ <p>To find the value the built-in uses FreeMarker's comparison
+ rules (as if you was using <a href="dgui_template_exp.html#dgui_template_exp_comparison"><code>==</code>
+ operator</a>), except that comparing two values of different
+ types or of types for which FreeMarker doesn't support comparison
+ will not cause error, just will be evaluated as the two values are
+ not equal. Thus, you can use it only to find scalar values (i.e.
+ string, number, boolean or date/time values). For other types the
+ result will be always <code class="inline-code">-1</code>.</p>
+
+ <p>The index where the searching is started can be optionally
+ given as the 2nd parameter. This may be useful if the same item can
+ occur for multiple times in the same sequence. There is no
+ restriction on the numerical value of the second parameter: if it is
+ negative, it has the same effect as if it were zero, and if it is
+ greater than the length of the sequence, it has the same effect as
+ if it were equal to the length of the sequence. Decimal values will
+ be truncated to integers. For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign names = ["Joe", "Fred", "Joe", "Susan"]>
+No 2nd param: ${names?seq_index_of("Joe")}
+-2: ${names?seq_index_of("Joe", -2)}
+-1: ${names?seq_index_of("Joe", -1)}
+ 0: ${names?seq_index_of("Joe", 0)}
+ 1: ${names?seq_index_of("Joe", 1)}
+ 2: ${names?seq_index_of("Joe", 2)}
+ 3: ${names?seq_index_of("Joe", 3)}
+ 4: ${names?seq_index_of("Joe", 4)}</pre></div>
+
+ <p>will output this:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">No 2nd param: 0
+-2: 0
+-1: 0
+ 0: 0
+ 1: 2
+ 2: 2
+ 3: -1
+ 4: -1</pre></div>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_seq_last_index_of">seq_last_index_of</h2>
+
+
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>This built-in is available since FreeMarker 2.3.1. It
+ doesn't exist in 2.3.</p>
+ </div>
+
+
+ <div class="callout note">
+ <strong class="callout-label">Note:</strong>
+
+ <p>The <code class="inline-code">seq_</code> prefix is required in the
+ built-in name to differentiate it from the <a href="ref_builtins_string.html#ref_builtin_last_index_of"><code>last_index_of</code>
+ built-in</a> that searches a substring in a string (since a
+ variable can be both string and sequence on the same time).</p>
+ </div>
+
+
+ <p>Returns the index of the last occurrence of a value in the
+ sequence, or <code class="inline-code">-1</code> if the sequence doesn't contain
+ the specified value. That is, it is the same as <a href="#ref_builtin_seq_index_of"><code>seq_index_of</code></a>,
+ just it searches backward starting from the last item of the
+ sequence. It also supports the optional 2nd parameter that specifies
+ the index where the searching is started. For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign names = ["Joe", "Fred", "Joe", "Susan"]>
+No 2nd param: ${names?seq_last_index_of("Joe")}
+-2: ${names?seq_last_index_of("Joe", -2)}
+-1: ${names?seq_last_index_of("Joe", -1)}
+ 0: ${names?seq_last_index_of("Joe", 0)}
+ 1: ${names?seq_last_index_of("Joe", 1)}
+ 2: ${names?seq_last_index_of("Joe", 2)}
+ 3: ${names?seq_last_index_of("Joe", 3)}
+ 4: ${names?seq_last_index_of("Joe", 4)}</pre></div>
+
+ <p>will output this:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">No 2nd param: 2
+-2: -1
+-1: -1
+ 0: 0
+ 1: 0
+ 2: 2
+ 3: 2
+ 4: 2</pre></div>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_size">size</h2>
+
+
+
+
+ <p>The number of sub variables in sequence (as a numerical
+ value). The highest possible index in sequence <code class="inline-code">s</code>
+ is <code class="inline-code">s?size�-�1</code> (since the index of the first
+ subvariable is 0) assuming that the sequence has at least one
+ subvariable.</p>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_sort">sort</h2>
+
+
+
+
+
+
+ <p>Returns the sequence sorted in ascending order. (For
+ descending order use this and then the <a href="#ref_builtin_reverse"><code>reverse</code> built
+ in</a>.) This will work only if all sub variables are strings, or
+ if all sub variables are numbers, or if all sub variables are date
+ values (date, time, or date+time), or if all sub variables are
+ booleans (since 2.3.17). If the sub variables are strings, it uses
+ locale (language) specific lexical sorting (which is usually not
+ case sensitive). For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign ls = ["whale", "Barbara", "zeppelin", "aardvark", "beetroot"]?sort>
+<#list ls as i>${i} </#list></pre></div>
+
+ <p>will print (with US locale at least):</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">aardvark Barbara beetroot whale zeppelin</pre></div>
+
+
+
+
+
+<h2 class="content-header header-section2" id="ref_builtin_sort_by">sort_by</h2>
+
+
+
+
+
+
+ <p>Returns the sequence of hashes sorted by the given hash
+ subvariable in ascending order. (For descending order use this and
+ then the <a href="#ref_builtin_reverse"><code>reverse</code> built
+ in</a>.) The rules are the same as with the <a href="#ref_builtin_sort"><code>sort</code> built-in</a>,
+ except that the sub variables of the sequence must be hashes, and
+ you have to give the name of a hash subvariable that will decide the
+ order. For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign ls = [
+ {"name":"whale", "weight":2000},
+ {"name":"Barbara", "weight":53},
+ {"name":"zeppelin", "weight":-200},
+ {"name":"aardvark", "weight":30},
+ {"name":"beetroot", "weight":0.3}
+]>
+Order by name:
+<#list ls?sort_by("name") as i>
+- ${i.name}: ${i.weight}
+</#list>
+
+Order by weight:
+<#list ls?sort_by("weight") as i>
+- ${i.name}: ${i.weight}
+</#list></pre></div>
+
+ <p>will print (with US locale at least):</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">Order by name:
+- aardvark: 30
+- Barbara: 53
+- beetroot: 0.3
+- whale: 2000
+- zeppelin: -200
+
+Order by weight:
+- zeppelin: -200
+- beetroot: 0.3
+- aardvark: 30
+- Barbara: 53
+- whale: 2000</pre></div>
+
+ <p>If the subvariable that you want to use for the sorting is on
+ a deeper level (that is, if it is a subvariable of a subvariable and
+ so on), then you can use a sequence as parameter, that specifies the
+ names of the sub variables that lead down to the desired
+ subvariable. For example:</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-template"><#assign members = [
+ {"name": {"first": "Joe", "last": "Smith"}, "age": 40},
+ {"name": {"first": "Fred", "last": "Crooger"}, "age": 35},
+ {"name": {"first": "Amanda", "last": "Fox"}, "age": 25}]>
+Sorted by name.last:
+<#list members?sort_by(['name', 'last']) as m>
+- ${m.name.last}, ${m.name.first}: ${m.age} years old
+</#list></pre></div>
+
+ <p>will print (with US locale at least):</p>
+
+
+
+<div class="code-wrapper"><pre class="code-block code-output">Sorted by name.last:
+- Crooger, Fred: 35 years old
+- Fox, Amanda: 25 years old
+- Smith, Joe: 40 years old</pre></div>
+ <div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="ref_builtins_boolean.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_builtins_hash.html"><span>Next</span></a></div></div></div></div> </div>
+ </div>
+<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="http://freemarker.org/">What is FreeMarker?</a></li><li><a href="http://freemarker.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="http://freemarker.org/history.html">About us</a></li><li><a itemprop="license" href="app_license.html">License</a></li></ul></div><div class="column"><h3 class="column-header">Handy stuff</h3><ul><li><a href="http://freemarker-online.kenshoo.com/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href
="https://github.com/freemarker/freemarker">FreeMarker on Github</a></li><li><a href="https://twitter.com/freemarker">Follow us on Twitter</a></li><li><a href="https://issues.apache.org/jira/browse/FREEMARKER/">Report a bug</a></li><li><a href="http://stackoverflow.com/questions/ask?tags=freemarker">Ask a question</a></li><li><a href="http://freemarker.org/mailing-lists.html">Mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/freemarker/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="http://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated">
+Last generated:
+<time itemprop="dateModified" datetime="2017-03-13T10:55:28Z" title="Monday, March 13, 2017 10:55:28 AM GMT">2017-03-13 10:55:28 GMT</time>, for Freemarker 2.3.26 </p>
+<p class="copyright">
+� <span itemprop="copyrightYear">1999</span>\u20132017
+<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. </p>
+</div></div></div></body>
+</html>