[Java] Class TemplateConfiguration
- groovy.text.markup.TemplateConfiguration
Configuration options for the markup template engine.
Properties Summary
Type | Name and description |
---|---|
boolean |
autoEscape |
boolean |
autoIndent |
String |
autoIndentString |
boolean |
autoNewLine |
Class<? extends BaseTemplate> |
baseTemplateClass |
boolean |
cacheTemplates |
String |
declarationEncoding |
boolean |
expandEmptyElements |
Locale |
locale |
String |
newLineString |
boolean |
useDoubleQuotes |
Constructor Summary
Constructor and description |
---|
TemplateConfiguration
() |
TemplateConfiguration
(TemplateConfiguration that) |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
String |
getAutoIndentString() | |
Class<? extends BaseTemplate> |
getBaseTemplateClass() | |
String |
getDeclarationEncoding() @return the encoding used in the declaration header | |
Locale |
getLocale() | |
String |
getNewLineString() | |
boolean |
isAutoEscape() @return true if variables in the model which are assignable to CharSequence should be automatically escaped. | |
boolean |
isAutoIndent() @return true if the template engine should handle indents automatically | |
boolean |
isAutoNewLine() | |
boolean |
isCacheTemplates() | |
boolean |
isExpandEmptyElements() @return whether elements without body should be written in the short form (ex: <br/>) or in an expanded form (ex: <br></br>) | |
boolean |
isUseDoubleQuotes() @return true if attributes should use double quotes instead of single quotes | |
void |
setAutoEscape(boolean autoEscape) Set to true if you want variables in the model which are assignable to CharSequence 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(String autoIndentString) | |
void |
setAutoNewLine(boolean autoNewLine) | |
void |
setBaseTemplateClass(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(String declarationEncoding) Set the encoding used to write the declaration header. | |
void |
setExpandEmptyElements(boolean expandEmptyElements) | |
void |
setLocale(Locale locale) | |
void |
setNewLineString(String newLineString) | |
void |
setUseDoubleQuotes(boolean useDoubleQuotes) |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Property Detail
boolean autoEscape
boolean autoIndent
String autoIndentString
boolean autoNewLine
Class<? extends BaseTemplate> baseTemplateClass
boolean cacheTemplates
String declarationEncoding
boolean expandEmptyElements
Locale locale
String newLineString
boolean useDoubleQuotes
Constructor Detail
public TemplateConfiguration()
public TemplateConfiguration(TemplateConfiguration that)
Method Detail
public String getAutoIndentString()
public Class<? extends BaseTemplate> getBaseTemplateClass()
public String getDeclarationEncoding()
- Returns:
- the encoding used in the declaration header
public Locale getLocale()
public String getNewLineString()
public boolean isAutoEscape()
- Returns:
- true if variables in the model which are assignable to CharSequence should be automatically escaped.
public boolean isAutoIndent()
- Returns:
- true if the template engine should handle indents automatically
public boolean isAutoNewLine()
public boolean isCacheTemplates()
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>)
public boolean isUseDoubleQuotes()
- Returns:
- true if attributes should use double quotes instead of single quotes
public void setAutoEscape(boolean autoEscape)
Set to true if you want variables in the model which are assignable to CharSequence 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
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 a DelegatingIndentWriter and indents are inserted after each call to newLine.
- Parameters:
-
autoIndent
- the auto-indent flag
public void setAutoIndentString(String autoIndentString)
public void setAutoNewLine(boolean autoNewLine)
public void setBaseTemplateClass(Class<? extends BaseTemplate> baseTemplateClass)
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 extending BaseTemplate
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
public void setDeclarationEncoding(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
public void setExpandEmptyElements(boolean expandEmptyElements)
public void setLocale(Locale locale)
public void setNewLineString(String newLineString)
public void setUseDoubleQuotes(boolean useDoubleQuotes)
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/2.5.14/html/gapi/groovy/text/markup/TemplateConfiguration.html