Package groovy.text.markup
Class TemplateConfiguration
java.lang.Object
groovy.text.markup.TemplateConfiguration
public class TemplateConfiguration
extends java.lang.Object
Configuration options for the
markup template engine
.-
Constructor Summary
Constructors Constructor Description TemplateConfiguration()
TemplateConfiguration(TemplateConfiguration that)
-
Method Summary
Modifier and Type Method Description java.lang.String
getAutoIndentString()
java.lang.Class<? extends BaseTemplate>
getBaseTemplateClass()
java.lang.String
getDeclarationEncoding()
java.util.Locale
getLocale()
java.lang.String
getNewLineString()
boolean
isAutoEscape()
boolean
isAutoIndent()
boolean
isAutoNewLine()
boolean
isCacheTemplates()
boolean
isExpandEmptyElements()
boolean
isUseDoubleQuotes()
void
setAutoEscape(boolean autoEscape)
Set to true if you want variables in the model which are assignable toCharSequence
to be escaped automatically in templates.void
setAutoIndent(boolean autoIndent)
Set this to true if you want the template engine to render indents automatically.void
setAutoIndentString(java.lang.String autoIndentString)
void
setAutoNewLine(boolean autoNewLine)
void
setBaseTemplateClass(java.lang.Class<? extends BaseTemplate> baseTemplateClass)
Set the template base class.void
setCacheTemplates(boolean cacheTemplates)
If cache is enabled, then templates are compiled once for each source (URL or File).void
setDeclarationEncoding(java.lang.String declarationEncoding)
Set the encoding used to write the declaration header.void
setExpandEmptyElements(boolean expandEmptyElements)
void
setLocale(java.util.Locale locale)
void
setNewLineString(java.lang.String newLineString)
void
setUseDoubleQuotes(boolean useDoubleQuotes)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
TemplateConfiguration
public TemplateConfiguration() -
TemplateConfiguration
-
-
Method Details
-
getDeclarationEncoding
public java.lang.String getDeclarationEncoding()- Returns:
- the encoding used in the declaration header
-
setDeclarationEncoding
public void setDeclarationEncoding(java.lang.String declarationEncoding)Set the encoding used to write the declaration header. Note that it is the responsibility of the user to ensure that it matches the writer encoding.- Parameters:
declarationEncoding
- encoding to be used in the declaration string
-
isExpandEmptyElements
public boolean isExpandEmptyElements()- Returns:
- whether elements without body should be written in the short form (ex: <br/>) or in an expanded form (ex: <br></br>)
-
setExpandEmptyElements
public void setExpandEmptyElements(boolean expandEmptyElements) -
isUseDoubleQuotes
public boolean isUseDoubleQuotes()- Returns:
- true if attributes should use double quotes instead of single quotes
-
setUseDoubleQuotes
public void setUseDoubleQuotes(boolean useDoubleQuotes) -
getNewLineString
public java.lang.String getNewLineString() -
setNewLineString
public void setNewLineString(java.lang.String newLineString) -
isAutoEscape
public boolean isAutoEscape()- Returns:
- true if variables in the model which are assignable to
CharSequence
should be automatically escaped.
-
setAutoEscape
public void setAutoEscape(boolean autoEscape)Set to true if you want variables in the model which are assignable toCharSequence
to be escaped automatically in templates. If this flag is set to true and that you want a value not to be automatically escaped, then you need to use ${unescaped.variable} instead of $variable- Parameters:
autoEscape
- value if the autoEscape flag
-
isAutoIndent
public boolean isAutoIndent()- Returns:
- true if the template engine should handle indents automatically
-
setAutoIndent
public void setAutoIndent(boolean autoIndent)Set this to true if you want the template engine to render indents automatically. In that case, the supplied writer is wrapped into aDelegatingIndentWriter
and indents are inserted after each call to newLine.- Parameters:
autoIndent
- the auto-indent flag
-
getAutoIndentString
public java.lang.String getAutoIndentString() -
setAutoIndentString
public void setAutoIndentString(java.lang.String autoIndentString) -
isAutoNewLine
public boolean isAutoNewLine() -
setAutoNewLine
public void setAutoNewLine(boolean autoNewLine) -
getBaseTemplateClass
-
setBaseTemplateClass
Set the template base class. You can use a distinct template class to provide more statically available data to your templates.- Parameters:
baseTemplateClass
- a class extendingBaseTemplate
-
getLocale
public java.util.Locale getLocale() -
setLocale
public void setLocale(java.util.Locale locale) -
isCacheTemplates
public boolean isCacheTemplates() -
setCacheTemplates
public void setCacheTemplates(boolean cacheTemplates)If cache is enabled, then templates are compiled once for each source (URL or File). It is recommended to keep this flag to true unless you are in development mode and want automatic reloading of templates.- Parameters:
cacheTemplates
- should templates be cached
-