Uses of Interface
freemarker.template.TemplateModel
Packages that use TemplateModel
Package
Description
The seldom used or advanced parts of the fundamental FreeMarker API, compared to
freemarker.template
.The default object wrapper of FreeMarker uses
this to expose Java Beans and POJO-s to templates.
Exposes DOM XML nodes to templates as easily traversable trees;
see in the Manual.
Deprecated, use W3C DOM (
freemarker.ext.dom
) instead;
Exposes JDOM XML nodes to templates.
Classes for two-way FreeMarker-JSP integration.
Exposes Jython objects to templates.
Exposes Rhino (ECMAScript) objects to templates.
Servlet for legacy "Model 2" frameworks that allows using FreeMarker
templates instead of JSP as the MVC View
(see in the Manual).
Various classes used by
freemarker.ext
but might be useful outside it too.Deprecated, use W3C DOM with
freemarker.ext.dom
instead;
Exposes XML from DOM, dom4j or JDOM nodes, uniformly.The fundamental, most commonly used API-s of FreeMarker;
start with
Configuration
(see also the
Getting Started in the Manual.)Various classes used by core FreeMarker code but might be useful outside of it too.
-
Uses of TemplateModel in freemarker.core
Subinterfaces of TemplateModel in freemarker.coreModifier and TypeInterfaceDescriptioninterface
TemplateMarkupOutputModel<MO extends TemplateMarkupOutputModel<MO>>
"markup output" template language data-type; stores markup (some kind of "rich text" / structured format, as opposed to plain text) that meant to be printed as template output.Classes in freemarker.core that implement TemplateModelModifier and TypeClassDescriptionclass
CommonTemplateMarkupOutputModel<MO extends CommonTemplateMarkupOutputModel<MO>>
Common superclass for implementingTemplateMarkupOutputModel
-s that belong to aCommonMarkupOutputFormat
subclass format.class
final class
Stores combined markup to be printed; used withCombinedMarkupOutputFormat
.class
Stores HTML markup to be printed; used withHTMLOutputFormat
.class
Stores RTF markup to be printed; used withRTFOutputFormat
.class
Stores HTML markup to be printed; used withHTMLOutputFormat
.class
Stores XML markup to be printed; used withXMLOutputFormat
.Methods in freemarker.core that return TemplateModelModifier and TypeMethodDescriptionEnvironment.getDataModelOrSharedVariable
(String name) Returns the variable from the data-model, or if it's not there, then from the Configuration.setSharedVariables(Map) shared variables}Environment.getGlobalVariable
(String name) Returns the globally visible variable of the given name, ornull
.Environment.getLocalVariable
(String name) Returns the loop or macro local variable corresponding to this variable name.Environment.getVariable
(String name) Returns the variable that is visible in this context, ornull
if the variable is not found.DefaultTruncateBuiltinAlgorithm.truncateCM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) abstract TemplateModel
TruncateBuiltinAlgorithm.truncateCM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) Corresponds to?truncate_c_m(...)
in templates.DefaultTruncateBuiltinAlgorithm.truncateM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) abstract TemplateModel
TruncateBuiltinAlgorithm.truncateM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) Corresponds to?truncate_m(...)
in templates.DefaultTruncateBuiltinAlgorithm.truncateWM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) abstract TemplateModel
TruncateBuiltinAlgorithm.truncateWM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) Corresponds to?truncate_w_m(...)
in templates.Methods in freemarker.core with parameters of type TemplateModelModifier and TypeMethodDescriptionboolean
Environment.applyEqualsOperator
(TemplateModel leftValue, TemplateModel rightValue) Compares twoTemplateModel
-s according the rules of the FTL "==" operator.boolean
Environment.applyEqualsOperatorLenient
(TemplateModel leftValue, TemplateModel rightValue) Compares twoTemplateModel
-s according the rules of the FTL "==" operator, except that if the two types are incompatible, they are treated as non-equal instead of throwing an exception.boolean
Environment.applyGreaterThanOperator
(TemplateModel leftValue, TemplateModel rightValue) Compares twoTemplateModel
-s according the rules of the FTL ">" operator.boolean
Environment.applyLessThanOperator
(TemplateModel leftValue, TemplateModel rightValue) Compares twoTemplateModel
-s according the rules of the FTL "<" operator.boolean
Environment.applyLessThanOrEqualsOperator
(TemplateModel leftValue, TemplateModel rightValue) Compares twoTemplateModel
-s according the rules of the FTL "<" operator.boolean
Environment.applyWithGreaterThanOrEqualsOperator
(TemplateModel leftValue, TemplateModel rightValue) Compares twoTemplateModel
-s according the rules of the FTL ">=" operator.static boolean
NonSequenceOrCollectionException.isWrappedIterable
(TemplateModel model) void
Environment.setGlobalVariable
(String name, TemplateModel value) Sets a variable in the global namespace, like<#global name=value>
.void
Environment.setLocalVariable
(String name, TemplateModel value) Sets a local variable that's on the top-level inside a macro or function invocation, like<#local name=value>
.void
Environment.setVariable
(String name, TemplateModel value) Sets a variable in the current namespace, like<#assign name=value>
.DefaultTruncateBuiltinAlgorithm.truncateCM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) abstract TemplateModel
TruncateBuiltinAlgorithm.truncateCM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) Corresponds to?truncate_c_m(...)
in templates.DefaultTruncateBuiltinAlgorithm.truncateM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) abstract TemplateModel
TruncateBuiltinAlgorithm.truncateM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) Corresponds to?truncate_m(...)
in templates.DefaultTruncateBuiltinAlgorithm.truncateWM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) abstract TemplateModel
TruncateBuiltinAlgorithm.truncateWM
(String s, int maxLength, TemplateModel terminator, Integer terminatorLength, Environment env) Corresponds to?truncate_w_m(...)
in templates. -
Uses of TemplateModel in freemarker.ext.beans
Classes in freemarker.ext.beans that implement TemplateModelModifier and TypeClassDescriptionclass
A class that will wrap an arbitrary array intoTemplateCollectionModel
andTemplateSequenceModel
interfaces.class
A class that will wrap an arbitrary object intoTemplateHashModel
interface allowing calls to arbitrary property getters and invocation of accessible methods on the object from a template using the object.foo to access properties and object.bar(arg1, arg2) to invoke methods on it.class
A class that will wrap instances ofBoolean
into aTemplateBooleanModel
.class
A special case ofBeanModel
that can wrap Java collections and that implements theTemplateCollectionModel
in order to be usable in a <#list> block.class
Wraps arbitrary subclass ofDate
into a reflective model.class
A class that addsTemplateModelIterator
functionality to theEnumeration
interface implementers.class
A class that addsTemplateModelIterator
functionality to theIterator
interface implementers.class
A special case ofBeanModel
that adds implementation forTemplateMethodModelEx
on map objects that is a shortcut for the Map.get() method.class
Wraps arbitrary subclass ofNumber
into a reflective model.class
Wraps a set of same-name overloaded methods behindTemplateMethodModel
interface, like if it was a single method, chooses among them behind the scenes on call-time based on the argument values.class
A hash model that wraps a resource bundle.class
Model used byBeansWrapper
when simpleMapWrapper mode is enabled.final class
A class that will wrap a reflected method call into aTemplateMethodModel
interface.class
Subclass ofBeanModel
that exposes the return value of theObject.toString()
method through theTemplateScalarModel
interface.Methods in freemarker.ext.beans that return TemplateModelModifier and TypeMethodDescriptionprotected TemplateModel
ArrayModel.get
(int index) Uses Beans introspection to locate a property or method with name matching the key name.CollectionModel.get
(int index) Retrieves the i-th object from the collection, wrapped as a TemplateModel.OverloadedMethodsModel.get
(int index) SimpleMethodModel.get
(int index) BeanModel.getAPI()
SimpleMapModel.getAPI()
protected TemplateModel
BeansWrapper.getInstance
(Object object, ModelFactory factory) Deprecated.HashAdapter.getTemplateModel()
protected TemplateModel
BeanModel.invokeGenericGet
(Map classInfo, Class<?> clazz, String key) protected TemplateModel
MapModel.invokeGenericGet
(Map keyMap, Class clazz, String key) Overridden to invoke the generic get method by casting to Map instead of through reflection - should yield better performance.protected TemplateModel
ResourceBundleModel.invokeGenericGet
(Map keyMap, Class clazz, String key) Overridden to invoke the getObject method of the resource bundle.protected TemplateModel
BeansWrapper.invokeMethod
(Object object, Method method, Object[] args) Invokes the specified method, wrapping the return value.EnumerationModel.next()
Calls underlyingEnumeration.nextElement()
and wraps the result.IteratorModel.next()
Calls underlyingIterator.next()
and wraps the result.protected TemplateModel
Reads the specified field, returns its value asTemplateModel
.protected TemplateModel
Wraps the object with a template model that is most specific for the object's class.Methods in freemarker.ext.beans with parameters of type TemplateModelModifier and TypeMethodDescriptionvoid
BeansWrapper.setNullModel
(TemplateModel nullModel) Deprecated.Changing thenull
model can cause a lot of confusion; don't do it.BeansWrapper.tryUnwrapTo
(TemplateModel model, Class<?> targetClass) protected Object
BeanModel.unwrap
(TemplateModel model) BeansWrapper.unwrap
(TemplateModel model) Attempts to unwrap a model into underlying object.BeansWrapper.unwrap
(TemplateModel model, Class<?> targetClass) Attempts to unwrap a model into an object of the desired class. -
Uses of TemplateModel in freemarker.ext.dom
Classes in freemarker.ext.dom that implement TemplateModelModifier and TypeClassDescriptionclass
A base class for wrapping a single W3C DOM Node as a FreeMarker template model.Methods in freemarker.ext.dom that return TemplateModelModifier and TypeMethodDescriptionXPathSupport.executeQuery
(Object context, String xpathQuery) final TemplateModel
NodeModel.get
(int i) -
Uses of TemplateModel in freemarker.ext.jdom
Classes in freemarker.ext.jdom that implement TemplateModelMethods in freemarker.ext.jdom that return TemplateModelModifier and TypeMethodDescriptionNodeListModel.get
(int i) Deprecated.Retrieves the i-th element of the node list.Deprecated.Provides node list traversal as well as special functions: filtering by name, filtering by node type, shallow-copying, and duplicate removal. -
Uses of TemplateModel in freemarker.ext.jsp
Classes in freemarker.ext.jsp that implement TemplateModelModifier and TypeClassDescriptionclass
A hash model associated with a servlet context that can load JSP tag libraries associated with that servlet context.Methods in freemarker.ext.jsp that return TemplateModelModifier and TypeMethodDescriptionRetrieves a JSP tag library identified by an URI. -
Uses of TemplateModel in freemarker.ext.jython
Classes in freemarker.ext.jython that implement TemplateModelModifier and TypeClassDescriptionclass
Model for Jython dictionaries (PyDictionary
andPyStringMap
).class
Generic model for arbitrary Jython objects.class
Model for Jython numeric objects (PyInteger
,PyLong
,PyFloat
).class
Model for Jython sequence objects (PySequence
descendants).Methods in freemarker.ext.jython that return TemplateModelModifier and TypeMethodDescriptionCallsPyObject.__findattr__(java.lang.String)
, then if it returns null callsPyObject.__finditem__(java.lang.String)
.JythonSequenceModel.get
(int index) ReturnsPyObject.__finditem__(int)
.Wraps the passed Jython object into a FreeMarker template model.Methods in freemarker.ext.jython with parameters of type TemplateModelModifier and TypeMethodDescriptionorg.python.core.PyObject
JythonWrapper.unwrap
(TemplateModel model) Coerces a template model into aPyObject
. -
Uses of TemplateModel in freemarker.ext.rhino
Classes in freemarker.ext.rhino that implement TemplateModelMethods in freemarker.ext.rhino that return TemplateModel -
Uses of TemplateModel in freemarker.ext.servlet
Classes in freemarker.ext.servlet that implement TemplateModelModifier and TypeClassDescriptionclass
An extension of SimpleHash that looks up keys in the hash, then in the request, session, and servlet context scopes.final class
TemplateHashModel wrapper for a HttpServletRequest attributes.class
TemplateHashModel wrapper for a HttpServletRequest parameters.final class
TemplateHashModel wrapper for a HttpSession attributes.class
A model that when invoked with a 'path' parameter will perform a servlet include.final class
TemplateHashModel wrapper for a ServletContext attributes.Methods in freemarker.ext.servlet that return TemplateModelModifier and TypeMethodDescriptionprotected TemplateModel
FreemarkerServlet.createModel
(ObjectWrapper objectWrapper, javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Methods in freemarker.ext.servlet with parameters of type TemplateModelModifier and TypeMethodDescriptionvoid
IncludePage.execute
(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) protected void
FreemarkerServlet.postTemplateProcess
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Template template, TemplateModel data) Called after the execution returns fromTemplate.process(Object, java.io.Writer)
.protected boolean
FreemarkerServlet.preTemplateProcess
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Template template, TemplateModel model) Called before the execution is passed toTemplate.process(Object, java.io.Writer)
.void
AllHttpScopesHashModel.putUnlistedModel
(String key, TemplateModel model) Stores a model in the hash so that it doesn't show up in keys() and values() methods. -
Uses of TemplateModel in freemarker.ext.util
Subinterfaces of TemplateModel in freemarker.ext.utilModifier and TypeInterfaceDescriptioninterface
A generic interface for template models that wrap some underlying object, and wish to provide access to that wrapped object.Methods in freemarker.ext.util that return TemplateModelModifier and TypeMethodDescriptionprotected abstract TemplateModel
ModelFactory.create
(Object object, ObjectWrapper wrapper) Create a wrapping model for the specified object that belongs to the specified wrapper.ModelCache.getInstance
(Object object) -
Uses of TemplateModel in freemarker.ext.xml
Classes in freemarker.ext.xml that implement TemplateModelMethods in freemarker.ext.xml that return TemplateModelModifier and TypeMethodDescriptionNodeListModel.get
(int index) Deprecated.Selects a single node from this model's nodelist by its list index and returns a new NodeListModel containing that single node.Deprecated.Returns a new NodeListModel containing the nodes that result from applying an operator to this model's nodes. -
Uses of TemplateModel in freemarker.template
Subinterfaces of TemplateModel in freemarker.templateModifier and TypeInterfaceDescriptioninterface
ATemplateModel
that can be unwrapped and then it considers a provided desired (hint) class.interface
"boolean" template language data type; same as in Java; eithertrue
orfalse
.interface
"collection" template language data type: a collection of values that can be enumerated, but can't be or not meant to be accessed by index or key, nor the number of elements in it is known.interface
"collection" template language data type: Adds size/emptiness querybility toTemplateCollectionModel
.interface
"date", "time" and "date-time" template language data types: corresponds toDate
.interface
"directive" template language data type: used as user-defined directives (much like macros) in templates.interface
"hash" template language data type: an object that contains other objects accessible through string keys (sub-variable names).interface
"extended hash" template language data type; extendsTemplateHashModel
by allowing iterating through its keys and values.interface
Adds key-value pair listing capability toTemplateHashModelEx
.interface
Deprecated.UseTemplateMethodModelEx
instead.interface
"extended method" template language data type: Objects that act like functions.interface
ATemplateModel
on which the?api
operation can be applied.interface
"node" template language data type: an object that is a node in a tree.interface
ATemplateNodeModel
that supports navigating to the previous and next sibling nodes.interface
"number" template language data type; an object that stores a number.interface
"string" template language data-type; like in Java, an unmodifiable UNICODE character sequence.interface
"sequence" template language data type; an object that contains other objects accessible through an integer 0-based index.interface
"transform" template language data type: user-defined directives (much like macros) specialized on filtering output; you should rather use the newerTemplateDirectiveModel
instead.Classes in freemarker.template that implement TemplateModelModifier and TypeClassDescriptionclass
Adapts anarray
of a non-primitive elements to the correspondingTemplateModel
interface(s), most importantly toTemplateHashModelEx
.class
Adapts anEnumeration
to the correspondingTemplateModel
interface(s), most importantly toTemplateCollectionModel
.class
Adapts anIterable
to the correspondingTemplateModel
interface(s), most importantly toTemplateCollectionModel
.class
Adapts anIterator
to the correspondingTemplateModel
interface(s), most importantly toTemplateCollectionModel
.class
Adapts aList
to the correspondingTemplateModel
interface(s), most importantly toTemplateSequenceModel
.class
Adapts aMap
to the correspondingTemplateModel
interface(s), most importantly toTemplateHashModelEx
.class
Adapts a non-List
JavaCollection
to the correspondingTemplateModel
interface(s), most importantly toTemplateCollectionModelEx
.class
An abstract base class for scalars that vary by locale.class
A concrete implementation ofLocalizedString
that gets a localized string from aResourceBundle
class
A simple implementation ofTemplateCollectionModel
.class
A simple implementation of the TemplateDateModel interface.class
A simple implementation of theTemplateHashModelEx
interface, using its own underlyingMap
orSortedMap
for storing the hash entries.class
Deprecated.UseSimpleSequence
instead.final class
A simple implementation of the TemplateNumberModel interface.final class
A simple implementation of the TemplateScalarModel interface, using a String.class
A simple implementation of theTemplateSequenceModel
interface, using its own underlyingList
for storing the list items.class
A sequence that wraps aList
ofTemplateModel
-s.Fields in freemarker.template declared as TemplateModelModifier and TypeFieldDescriptionstatic final TemplateModel
TemplateScalarModel.EMPTY_STRING
A constant value to use as the empty string.static final TemplateModel
TemplateModel.NOTHING
A general-purpose object to represent nothing.Methods in freemarker.template that return TemplateModelModifier and TypeMethodDescriptionDefaultListAdapter.get
(int index) SimpleSequence.get
(int index) Returns the item at the specified index of the list.Gets a TemplateModel from the hash.TemplateModelListSequence.get
(int index) TemplateSequenceModel.get
(int index) Retrieves the i-th template model in this sequence.DefaultEnumerationAdapter.getAPI()
DefaultIterableAdapter.getAPI()
DefaultIteratorAdapter.getAPI()
DefaultListAdapter.getAPI()
DefaultMapAdapter.getAPI()
DefaultNonListCollectionAdapter.getAPI()
TemplateModelWithAPISupport.getAPI()
Returns the model that exposes the (Java) API of the value.TemplateHashModelEx2.KeyValuePair.getKey()
Configuration.getSharedVariable
(String name) Gets a shared variable.TemplateModelAdapter.getTemplateModel()
TemplateHashModelEx2.KeyValuePair.getValue()
protected TemplateModel
DefaultObjectWrapper.handleUnknownType
(Object obj) Called for an object that isn't considered to be of a "basic" Java type, like for an application specific type, or for a W3C DOM node.protected TemplateModel
SimpleObjectWrapper.handleUnknownType
(Object obj) Called if a type other than the simple ones we know about is passed in.TemplateModelIterator.next()
Returns the next model.Wraps the parameter object toTemplateModel
interface(s).Makes aTemplateModel
out of a non-TemplateModel
object, usually by "wrapping" it into aTemplateModel
implementation that delegates to the original object.protected final TemplateModel
Wraps the passed object into a template model using this object's object wrapper.DefaultObjectWrapper.wrapDomNode
(Object obj) Methods in freemarker.template with parameters of type TemplateModelModifier and TypeMethodDescriptionboolean
DefaultNonListCollectionAdapter.contains
(TemplateModel item) void
TemplateDirectiveModel.execute
(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) Executes this user-defined directive; called by FreeMarker when the user-defined directive is called in the template.void
Configuration.setSharedVariable
(String name, TemplateModel tm) Adds a shared variable to the configuration.ObjectWrapperAndUnwrapper.tryUnwrapTo
(TemplateModel tm, Class<?> targetClass) Attempts to unwrap aTemplateModel
to a plain Java object that's the instance of the given class (or isnull
).ObjectWrapperAndUnwrapper.unwrap
(TemplateModel tm) Unwraps aTemplateModel
to a plain Java object. -
Uses of TemplateModel in freemarker.template.utility
Classes in freemarker.template.utility that implement TemplateModelModifier and TypeClassDescriptionclass
Deprecated.Use block-assignments instead, like<assign x>...</assign>
.class
Deprecated.UseNodeModel
insteadclass
Gives FreeMarker the the ability to execute external commands.class
Performs an HTML escape of a given template fragment.class
A crude first pass at an embeddable Jython interpreterclass
Transformer that supports FreeMarker legacy behavior: all newlines appearing within the transformed area will be transformed into the platform's default newline.class
An object that you can make available in a template to instantiate arbitrary beans-wrapped objects in a template.class
A filter that compresses each sequence of consecutive whitespace to a single line break (if the sequence contains a line break) or a single space.class
Performs an XML escaping of a given template fragment.Methods in freemarker.template.utility that return TemplateModelMethods in freemarker.template.utility with parameters of type TemplateModelModifier and TypeMethodDescriptionstatic String
ClassUtil.getFTLTypeDescription
(TemplateModel tm) Returns the type description of a value with FTL terms (not plain class name), as it should be used in type-related error messages and for debugging purposes.static Object
DeepUnwrap.permissiveUnwrap
(TemplateModel model) Same asDeepUnwrap.unwrap(TemplateModel)
, but it doesn't throw exception if it doesn't know how to unwrap the model, but rather returns it as-is.static Object
DeepUnwrap.premissiveUnwrap
(TemplateModel model) Deprecated.the name of this method is mistyped.static Object
DeepUnwrap.unwrap
(TemplateModel model) UnwrapsTemplateModel
-s recursively.
BeansWrapper.getModelFactory(Class)
instead.