| <!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>setting - 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="setting"> |
| <meta property="og:locale" content="en_US"> |
| <meta property="og:url" content="http://example.com/ref_directive_setting.html"> |
| <link rel="canonical" href="http://example.com/ref_directive_setting.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_directives.html"><span itemprop="name">Directive Reference</span></a></li><li class="step-3" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="ref_directive_setting.html"><span itemprop="name">setting</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_directive_local.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_directive_userDefined.html"><span>Next</span></a></div><div class="title-wrapper"> |
| <h1 class="content-header header-section1" id="ref_directive_setting" itemprop="headline">setting</h1> |
| </div></div><div class="page-menu"> |
| <div class="page-menu-title">Page Contents</div> |
| <ul><li><a class="page-menu-link" href="#autoid_100" data-menu-target="autoid_100">Synopsis</a></li><li><a class="page-menu-link" href="#autoid_101" data-menu-target="autoid_101">Description</a></li></ul> </div><a name="ref.directive.setting"></a> |
| |
| |
| |
| |
| <h2 class="content-header header-section2" id="autoid_100">Synopsis</h2> |
| |
| |
| |
| <pre class="metaTemplate"> |
| <code class="inline-code"><#setting <em class="code-color">name</em>=<em class="code-color">value</em>></code> |
| </pre> |
| |
| |
| <p>Where:</p> |
| |
| <ul> |
| <li> |
| <code class="inline-code"><em class="code-color">name</em></code>: name |
| of the setting. It is not expression! |
| </li> |
| |
| <li> |
| <code class="inline-code"><em class="code-color">value</em></code>: New |
| value of the setting. Expression |
| </li> |
| </ul> |
| |
| |
| |
| |
| |
| <h2 class="content-header header-section2" id="autoid_101">Description</h2> |
| |
| |
| <p>Sets a setting for the further part of processing. Settings |
| are values that influence the behavior of FreeMarker. The new value |
| will be present only in the template processing where it was set, |
| and does not touch the template itself. The initial value of |
| settings is set by the programmer <span class="marked-for-programmers">(see: <a href="pgui_config_settings.html">Programmer's Guide/The Configuration/Settings</a>)</span>.</p> |
| |
| <p>The supported settings are:</p> |
| |
| <ul> |
| <li> |
| <p><code class="inline-code">locale</code>: The locale (language) |
| of the output. It can influence the presentation format of |
| numbers, dates, etc. The value is a string which consist of a |
| language code (lowercase two-letter ISO-639 code) plus optional |
| county code (uppercase two-letter ISO-3166 code) separated from |
| the language code with underscore, and if we have specified the |
| country then an optional variant code (not standardized) |
| separated from the country with underscore. Examples of valid |
| values: <code class="inline-code">en</code>, <code class="inline-code">en_US</code>, |
| <code class="inline-code">en_US_MAC</code>. FreeMarker will try to use the |
| most specific available locale, so if you specify |
| <code class="inline-code">en_US_MAC</code> but that is not known, then it will |
| try <code class="inline-code">en_US</code>, and then <code class="inline-code">en</code>, |
| and then the default locale of the computer (which is may set by |
| the programmer).</p> |
| </li> |
| |
| <li> |
| <p><a name="ref.setting.number_format"></a><code class="inline-code">number_format</code>: The number |
| format that is used to convert numbers to strings when no |
| explicit format is specified. Can be one of predefined values |
| <code class="inline-code">number</code> (the default), |
| <code class="inline-code">computer</code>, <code class="inline-code">currency</code>, or |
| <code class="inline-code">percent</code>. Additionally, arbitrary format |
| pattern written in <a href="http://java.sun.com/j2se/1.4/docs/api/java/text/DecimalFormat.html">Java |
| decimal number format syntax</a> can also be specified. More |
| information about format patterns:<a href="ref_builtins_number.html#ref_builtin_string_for_number"><code>string</code> |
| built-in</a>.</p> |
| </li> |
| |
| <li> |
| <p><code class="inline-code">boolean_format</code>: The |
| comma-separated pair of strings for representing true and false |
| values respectively that is used to convert booleans to strings |
| when no explicit format is specified. Default value is |
| <code class="inline-code">"true,false"</code>. See also:<a href="ref_builtins_boolean.html#ref_builtin_string_for_boolean"><code>string</code> |
| built-in</a>.</p> |
| </li> |
| |
| <li> |
| <p> <code class="inline-code">date_format</code>, |
| <code class="inline-code">time_format</code>, |
| <code class="inline-code">datetime_format</code>: The date/time format used to |
| convert dates to strings when no explicit format is specified, |
| as in the case of <code class="inline-code">${someDate}</code>. |
| <code class="inline-code">date_format</code> affects only the formatting of |
| date-only dates (year, month, day), |
| <code class="inline-code">time_format</code> affects only the formatting of |
| time-only dates (hour,minute, second, millisecond), |
| <code class="inline-code">datetime_format</code> affects only the formatting |
| of date-time dates (year, month, day, hour, minute, second, |
| millisecond). The possible values of the settings are similar to |
| the parameters of <a href="ref_builtins_date.html#ref_builtin_string_for_date"><code>string</code> |
| built-in</a> of dates; see more explanation there. Examples: |
| <code class="inline-code">"short"</code>, <code class="inline-code">"long_medium"</code>, |
| <code class="inline-code">"MM/dd/yyyy"</code>.</p> |
| </li> |
| |
| <li> |
| <p><code class="inline-code">time_zone</code>: The name of the time |
| zone used to format times for display. By default, the system |
| time zone is used. Can be any value that is accepted by <a href="http://java.sun.com/j2se/1.4/docs/api/java/util/TimeZone.html">Java |
| TimeZone API</a>. Examples: <code class="inline-code">"GMT"</code>, |
| <code class="inline-code">"GMT+2"</code>, <code class="inline-code">"GMT-1:30"</code>, |
| <code class="inline-code">"CET"</code>, <code class="inline-code">"PST"</code>, |
| <code class="inline-code">"America/Los_Angeles"</code></p> |
| </li> |
| |
| <li> |
| <p><code class="inline-code">url_escaping_charset</code>: The |
| charset used for URL escaping (e.g. for |
| <code class="inline-code">${foo?url}</code>) to calculate the escaped |
| (<code class="inline-code">%<em class="code-color">XX</em></code>) parts. |
| Usually the framework that encloses FreeMarker should set it, so |
| you hardly ever should set this setting in templates. <span class="marked-for-programmers">(Programmers can read more about this |
| <a href="pgui_misc_charset.html">here...</a>)</span></p> |
| </li> |
| |
| <li> |
| <p><code class="inline-code">classic_compatible</code>: This is for |
| experts. Its value should be a boolean. See the documentation of |
| <code class="inline-code">freemarker.template.Configurable</code> for more |
| information.</p> |
| </li> |
| </ul> |
| |
| <p>Example: Assume that the initial locale of template is hu |
| (Hungarian). Then this:</p> |
| |
| |
| |
| <div class="code-wrapper"><pre class="code-block code-template">${1.2} |
| <#setting locale="en_US"> |
| ${1.2}</pre></div> |
| |
| <p>will output this:</p> |
| |
| |
| |
| <div class="code-wrapper"><pre class="code-block code-output">1,2 |
| 1.2</pre></div> |
| |
| <p>because Hungarian people use the comma as their decimal |
| separator, while US people use the dot.</p> |
| <div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="ref_directive_local.html"><span>Previous</span></a><a class="paging-arrow next" href="ref_directive_userDefined.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> |