Settings

Settings are named values that influence the behavior of FreeMarker. Examples of settings are: locale, number_format

Settings stored in Configuration instance can be overridden in a Template instance. For example you set "en_US" for the locale setting in the configuration, then the locale in all templates that use this configuration will be "en_US", except in templates where you have overridden that with the setLocale method of Template. Thus, values in a configuration serve as defaults that can be overridden in a per template manner. The value comes from Configuration instance or Template instance can be further overridden for a single Template.process call with the setting directive. The thing that stores the state of single a Template.process call is called the runtime environment of the process call; setting values that override the values comes from Template instance or Configuration instance are stored there.

This can be imagined as 3 layers (configuration, template, runtime environment) of settings, where the topmost layer that contains the value for a certain setting provides the effective value of that setting. For example (settings A to F are just imaginary settings for this example):

Setting A Setting B Setting C Setting D Setting E Setting F
Layer 3: Runtime environment 1 - - 1 - -
Layer 2: Template 2 2 - - 2 -
Layer 1: Configuration 3 3 3 3 - -

The effective value of settings will be: A = 1, B = 2, C = 3, D = 1, E = 2. The F setting is probably Java null, or it throws exception when you try to get it.

To see the list of supported settings, please read the following parts of the FreeMarker Java API documentation:

  • freemarker.core.Configurable.setSetting(String, String): Settings that live in all layers.

  • freemarker.template.Configuration.setSetting(String, String): Coniguration layer settings.


Page generated: 2007-12-05 00:36:54 GMT FreeMarker Manual -- For FreeMarker 2.3.11