Modifier and Type | Field and Description |
---|---|
Mustache.Collector |
collector
The collector used by templates compiled with this compiler.
|
com.samskivert.mustache.Mustache.Delims |
delims
The delimiters used by default in templates compiled with this compiler.
|
boolean |
emptyStringIsFalse
If this value is true, empty string will be treated as a false value, as in JavaScript
mustache implementation.
|
Mustache.Escaper |
escaper
Handles escaping characters in substituted text.
|
Mustache.Formatter |
formatter
Handles converting objects to strings when rendering a template.
|
Mustache.TemplateLoader |
loader
The template loader in use during this compilation.
|
boolean |
missingIsNull
If this value is true, missing variables will be treated like variables that return
null.
|
String |
nullValue
A value to use when a variable resolves to null.
|
boolean |
standardsMode
Whether or not standards mode is enabled.
|
boolean |
strictSections
Whether or not to throw an exception when a section resolves to a missing value.
|
boolean |
zeroIsFalse
If this value is true, zero will be treated as a false value, as in JavaScript
mustache implementation.
|
Modifier and Type | Method and Description |
---|---|
Template |
compile(Reader source)
Compiles the supplied template into a repeatedly executable intermediate form.
|
Template |
compile(String template)
Compiles the supplied template into a repeatedly executable intermediate form.
|
String |
computeNullValue(String name)
Returns the value to use in the template for the null-valued property
name . |
Mustache.Compiler |
defaultValue(String defaultValue)
Returns a compiler that will use the given value for any variable that is missing, or
otherwise resolves to null.
|
Mustache.Compiler |
emptyStringIsFalse(boolean emptyStringIsFalse)
Returns a compiler that will treat empty string as a false value if parameter is true.
|
Mustache.Compiler |
escapeHTML(boolean escapeHTML)
Returns a compiler that either does or does not escape HTML by default.
|
boolean |
isFalsey(Object value)
Returns true if the supplied value is "falsey".
|
Mustache.Compiler |
nullValue(String nullValue)
Returns a compiler that will use the given value for any variable that resolves to
null, but will still raise an exception for variables for which an accessor cannot be
found.
|
Mustache.Compiler |
standardsMode(boolean standardsMode)
Returns a compiler that either does or does not use standards mode.
|
Mustache.Compiler |
strictSections(boolean strictSections)
Returns a compiler that throws an exception when a section references a missing value
(
true ) or treats a missing value as false (false , the default). |
Mustache.Compiler |
withCollector(Mustache.Collector collector)
Returns a compiler configured to use the supplied collector.
|
Mustache.Compiler |
withDelims(String delims)
Returns a compiler configured to use the supplied delims as default delimiters.
|
Mustache.Compiler |
withEscaper(Mustache.Escaper escaper)
Configures the
Mustache.Escaper used to escape substituted text. |
Mustache.Compiler |
withFormatter(Mustache.Formatter formatter)
Configures the
Mustache.Formatter used to turn objects into strings. |
Mustache.Compiler |
withLoader(Mustache.TemplateLoader loader)
Returns a compiler configured to use the supplied template loader to handle partials.
|
Mustache.Compiler |
zeroIsFalse(boolean zeroIsFalse)
Returns a compiler that will treat zero as a false value if parameter is true.
|
public final boolean standardsMode
public final boolean strictSections
MustacheException
is thrown.public final String nullValue
missingIsNull
is also
true, this value will be used when a variable cannot be resolved.
If the nullValue contains a substring {{name}}
, then this substring will be
replaced by name of the variable. For example, if nullValue is ?{{name}}?
and
the missing variable is foo
, then string ?foo?
will be used.
public final boolean missingIsNull
public final boolean emptyStringIsFalse
public final boolean zeroIsFalse
public final Mustache.Formatter formatter
String.valueOf(java.lang.Object)
.public final Mustache.Escaper escaper
public final Mustache.TemplateLoader loader
public final Mustache.Collector collector
public final com.samskivert.mustache.Mustache.Delims delims
public Template compile(String template)
public Template compile(Reader source)
public Mustache.Compiler escapeHTML(boolean escapeHTML)
withEscaper(com.samskivert.mustache.Mustache.Escaper)
.public Mustache.Compiler standardsMode(boolean standardsMode)
public Mustache.Compiler strictSections(boolean strictSections)
true
) or treats a missing value as false
(false
, the default).public Mustache.Compiler defaultValue(String defaultValue)
nullValue
except that it returns the
supplied default for missing keys and existing keys that return null values.public Mustache.Compiler nullValue(String nullValue)
defaultValue(java.lang.String)
except that it differentiates between missing
accessors, and accessors that exist but return null.
Map
being used as a context, if the map does not contain
a mapping for a variable, an exception will be raised. If the map contains a mapping
which maps to null
, then nullValue
is used.public Mustache.Compiler emptyStringIsFalse(boolean emptyStringIsFalse)
public Mustache.Compiler zeroIsFalse(boolean zeroIsFalse)
public Mustache.Compiler withFormatter(Mustache.Formatter formatter)
Mustache.Formatter
used to turn objects into strings.public Mustache.Compiler withEscaper(Mustache.Escaper escaper)
Mustache.Escaper
used to escape substituted text.public Mustache.Compiler withLoader(Mustache.TemplateLoader loader)
public Mustache.Compiler withCollector(Mustache.Collector collector)
public Mustache.Compiler withDelims(String delims)
delims
- a string of the form AB CD
or A D
where A and B are
opening delims and C and D are closing delims.public String computeNullValue(String name)
name
. See
nullValue
for more details.public boolean isFalsey(Object value)
emptyStringIsFalse
is true,
then empty strings are considered falsey. If zeroIsFalse
is true, then zero
values are considered falsey.Copyright © 2016. All rights reserved.