Class Mustache
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 classAn abstract segment that is a template include.protected static classA helper class for section-like segments.protected static classprotected static interfaceprotected static classA parent partial parameter using $ as the sigil.static interfaceHandles interpreting objects as collections.static classCompiles templates into executable form.static interfaceProvides a means to implement custom logic for variable lookup.protected static classstatic interfaceHandles escaping characters in substituted text.protected static classstatic interfaceHandles converting objects to strings when rendering templates.protected static classA segment that loads and executes a sub-template by spec called a partial.protected static classA segment that represents an inverted section.static interfaceHandles lambdas that are also invoked for inverse sections..static interfaceHandles lambdas.protected static classA helper class for named segments.protected static classA segment that loads and executes a parent template by spec called inheritance.protected static classprotected static classA segment that represents a section.protected static interfaceprotected static classA simple segment that reproduces a string.static interfaceHandles loading partial templates.static interfaceReads variables from context objects.protected static classA segment that substitutes the contents of a variable.static interfaceUsed to visit the tags in a template without executing it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Mustache.Formatterprotected static final Mustache.TemplateLoaderprotected static final intprotected static final intprotected static final charUsed when we have only a single character delimiter.protected static final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanallowsWhitespace(char typeChar) protected static Templatecompile(Reader source, Mustache.Compiler compiler) Compiles the supplied template into a repeatedly executable intermediate form.static Mustache.Compilercompiler()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 voidrestoreStartTag(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)
-