setting
Page Contents
Synopsis
<#setting name=value>
Where:
- name: name of the setting. It is not expression!
- value: New value of the setting. Expression
Description
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 (see: Programmer's Guide/The Configuration/Settings).
The supported settings are:
-
locale: 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: en, en_US, en_US_MAC. FreeMarker will try to use the most specific available locale, so if you specify en_US_MAC but that is not known, then it will try en_US, and then en, and then the default locale of the computer (which is may set by the programmer).
-
number_format: The number format that is used to convert numbers to strings when no explicit format is specified. Can be one of predefined values number (the default), computer, currency, or percent. Additionally, arbitrary format pattern written in Java decimal number format syntax can also be specified. More information about format patterns:string built-in.
-
boolean_format: 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 "true,false". See also:string built-in.
-
date_format, time_format, datetime_format: The date/time format used to convert dates to strings when no explicit format is specified, as in the case of ${someDate}. date_format affects only the formatting of date-only dates (year, month, day), time_format affects only the formatting of time-only dates (hour,minute, second, millisecond), datetime_format 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 string built-in of dates; see more explanation there. Examples: "short", "long_medium", "MM/dd/yyyy".
-
time_zone: 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 Java TimeZone API. Examples: "GMT", "GMT+2", "GMT-1:30", "CET", "PST", "America/Los_Angeles"
-
url_escaping_charset: The charset used for URL escaping (e.g. for ${foo?url}) to calculate the escaped (%XX) parts. Usually the framework that encloses FreeMarker should set it, so you hardly ever should set this setting in templates. (Programmers can read more about this here...)
-
classic_compatible: This is for experts. Its value should be a boolean. See the documentation of freemarker.template.Configurable for more information.
Example: Assume that the initial locale of template is hu (Hungarian). Then this:
| |||
will output this:
| |||
because Hungarian people use the comma as their decimal separator, while US people use the dot.