TemplateModel (FreeMarker 2.3.23 API)
Date: 2015-07-05

freemarker.template

## Interface TemplateModel

- All Known Subinterfaces:
    AdapterTemplateModel, TemplateBooleanModel, TemplateCollectionModel, TemplateCollectionModelEx, TemplateDateModel, TemplateDirectiveModel, TemplateHashModel, TemplateHashModelEx, TemplateMethodModel, TemplateMethodModelEx, TemplateModelWithAPISupport, TemplateNodeModel, TemplateNumberModel, TemplateScalarModel, TemplateSequenceModel, TemplateTransformModel, WrapperTemplateModel
  All Known Implementing Classes:
    AllHttpScopesHashModel, ArrayModel, BeanModel, BooleanModel, CaptureOutput, CollectionModel, DateModel, DefaultArrayAdapter, DefaultIteratorAdapter, DefaultListAdapter, DefaultMapAdapter, DefaultNonListCollectionAdapter, DOMNodeModel, EnumerationModel, Environment.Namespace, Execute, HtmlEscape, HttpRequestHashModel, HttpRequestParametersHashModel, HttpSessionHashModel, IncludePage, IteratorModel, JythonHashModel, JythonModel, JythonNumberModel, JythonRuntime, JythonSequenceModel, LocalizedString, MapModel, NodeListModel, NodeListModel, NodeModel, NormalizeNewlines, NumberModel, ObjectConstructor, OverloadedMethodsModel, ResourceBundleLocalizedString, ResourceBundleModel, RhinoFunctionModel, RhinoScriptableModel, ServletContextHashModel, SimpleCollection, SimpleDate, SimpleHash, SimpleList, SimpleMapModel, SimpleMethodModel, SimpleNumber, SimpleScalar, SimpleSequence, StandardCompress, StringModel, TaglibFactory, TemplateModelListSequence, XmlEscape

      public interface TemplateModel

  The common super-interface of the interfaces that stand for the FreeMarker Template Language (FTL) data types. The template language only deals with `TemplateModel`-s, not directly with plain Java objects. (For example, it doesn't understand `Number`, but `TemplateNumberModel`.) This is why the data-model (aka. the "template context" in other languages) is (automatically) mapped to a tree of `TemplateModel`-s.

  Mapping the plain Java objects to `TemplateModel`-s (or the other way around sometimes) is the responsibility of the `ObjectWrapper` (can be set via `Configuration.setObjectWrapper(ObjectWrapper)`). But not all `TemplateModel`-s are for wrapping a plain object. For example, a value created within a template is not made to wrap an earlier existing object; it's a value that has always existed in the template language's domain. Users can also write `TemplateModel` implementations and put them directly into the data-model for full control over how that object is seen from the template. Certain `TemplateModel` interfaces doesn't even have equivalent in Java. For example the directive type (`TemplateDirectiveModel`) is like that.

  Because `TemplateModel` "subclasses" are all interfaces, a value in the template language can have multiple types. However, to prevent ambiguous situations, it's not recommended to make values that implement more than one of these types: string, number, boolean, date. The intended applications are like string+hash, string+method, hash+sequence, etc.

  See Also:
    `ClassUtil.getFTLTypeDescription(TemplateModel)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TemplateModel` | `NOTHING` A general-purpose object to represent nothing.

- - ### Field Detail

    - #### NOTHING

          static final TemplateModel NOTHING

      A general-purpose object to represent nothing. It acts as an empty string, false, empty sequence, empty hash, and null-returning method model.