java.lang.Object
com.samskivert.mustache.Mustache
Provides Mustache templating services.
Basic usage:
String source = "Hello {{arg}}!";
Template tmpl = Mustache.compiler().compile(source);
Map<String, Object> context = new HashMap<String, Object>();
context.put("arg", "world");
tmpl.execute(context); // returns "Hello world!"
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An abstract segment that is a template include.protected static class
A helper class for section-like segments.protected static class
protected static interface
protected static class
A parent partial parameter using $ as the sigil.static interface
Handles interpreting objects as collections.static class
Compiles templates into executable form.static interface
Provides a means to implement custom logic for variable lookup.protected static class
static interface
Handles escaping characters in substituted text.protected static class
static interface
Handles converting objects to strings when rendering templates.protected static class
A segment that loads and executes a sub-template by spec called a partial.protected static class
A segment that represents an inverted section.static interface
Handles lambdas that are also invoked for inverse sections..static interface
Handles lambdas.protected static class
A helper class for named segments.protected static class
A segment that loads and executes a parent template by spec called inheritance.protected static class
protected static class
A segment that represents a section.protected static interface
protected static class
A simple segment that reproduces a string.static interface
Handles loading partial templates.static interface
Reads variables from context objects.protected static class
A segment that substitutes the contents of a variable.static interface
Used to visit the tags in a template without executing it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Mustache.Formatter
protected static final Mustache.TemplateLoader
protected static final int
protected static final int
protected static final char
Used when we have only a single character delimiter.protected static final int
protected static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
allowsWhitespace
(char typeChar) protected static Template
compile
(Reader source, Mustache.Compiler compiler) Compiles the supplied template into a repeatedly executable intermediate form.static Mustache.Compiler
compiler()
Returns a compiler that escapes HTML by default and does not use standards mode.(package private) static Template.Segment[]
indentSegs
(Template.Segment[] _segs, String indent, boolean _first, boolean _last) Indents segments by indent.(package private) static Template.Segment[]
replaceBlockSegs
(Template.Segment[] _segs, Map<String, Mustache.BlockSegment> blocks) protected static void
restoreStartTag
(StringBuilder text, Mustache.Delims starts) protected static Template.Segment[]
trim
(Template.Segment[] segs, boolean top)
-
Field Details
-
TEXT
protected static final int TEXT- See Also:
-
MATCHING_START
protected static final int MATCHING_START- See Also:
-
MATCHING_END
protected static final int MATCHING_END- See Also:
-
TAG
protected static final int TAG- See Also:
-
NO_CHAR
protected static final char NO_CHARUsed when we have only a single character delimiter.- See Also:
-
FAILING_LOADER
-
DEFAULT_FORMATTER
-
-
Constructor Details
-
Mustache
private Mustache()
-
-
Method Details
-
compiler
Returns a compiler that escapes HTML by default and does not use standards mode. -
compile
Compiles the supplied template into a repeatedly executable intermediate form. -
trim
-
indentSegs
static Template.Segment[] indentSegs(Template.Segment[] _segs, String indent, boolean _first, boolean _last) Indents segments by indent.- Parameters:
_segs
- segments to be cloned if indentation is neededindent
- the space to use for indent._first
- whether to append an indent on the first segment_last
- whether to append an indent on the last segment last empty newline (no character after \n).- Returns:
- cloned segments if changed
-
replaceBlockSegs
static Template.Segment[] replaceBlockSegs(Template.Segment[] _segs, Map<String, Mustache.BlockSegment> blocks) -
restoreStartTag
-
allowsWhitespace
protected static boolean allowsWhitespace(char typeChar)
-