- java.lang.Object
-
- com.samskivert.mustache.Mustache
-
public class Mustache extends java.lang.ObjectProvides 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 Classes Modifier and Type Class Description protected static classMustache.AbstractPartialSegmentAn abstract segment that is a template include.protected static classMustache.AbstractSectionSegmentA helper class for section-like segments.protected static classMustache.Accumulatorprotected static interfaceMustache.BlockReplaceableprotected static classMustache.BlockSegmentA parent partial parameter using $ as the sigil.static interfaceMustache.CollectorHandles interpreting objects as collections.static classMustache.CompilerCompiles templates into executable form.static interfaceMustache.CustomContextProvides a means to implement custom logic for variable lookup.protected static classMustache.Delimsstatic interfaceMustache.EscaperHandles escaping characters in substituted text.protected static classMustache.FauxSegmentstatic interfaceMustache.FormatterHandles converting objects to strings when rendering templates.protected static classMustache.IncludedTemplateSegmentA segment that loads and executes a sub-template by spec called a partial.protected static classMustache.InvertedSegmentA segment that represents an inverted section.static interfaceMustache.InvertibleLambdaHandles lambdas that are also invoked for inverse sections..static interfaceMustache.LambdaHandles lambdas.protected static classMustache.NamedSegmentA helper class for named segments.protected static classMustache.ParentTemplateSegmentA segment that loads and executes a parent template by spec called inheritance.protected static classMustache.Parserprotected static classMustache.SectionSegmentA segment that represents a section.protected static interfaceMustache.StandaloneSectionprotected static classMustache.StringSegmentA simple segment that reproduces a string.static interfaceMustache.TemplateLoaderHandles loading partial templates.static interfaceMustache.VariableFetcherReads variables from context objects.protected static classMustache.VariableSegmentA segment that substitutes the contents of a variable.static interfaceMustache.VisitorUsed to visit the tags in a template without executing it.
-
Field Summary
Fields Modifier and Type Field Description protected static Mustache.FormatterDEFAULT_FORMATTERprotected static Mustache.TemplateLoaderFAILING_LOADERprotected static intMATCHING_ENDprotected static intMATCHING_STARTprotected static charNO_CHARUsed when we have only a single character delimiter.protected static intTAGprotected static intTEXT
-
Constructor Summary
Constructors Modifier Constructor Description privateMustache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static booleanallowsWhitespace(char typeChar)protected static Templatecompile(java.io.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, java.lang.String indent, boolean _first, boolean _last)Indents segments by indent.(package private) static Template.Segment[]replaceBlockSegs(Template.Segment[] _segs, java.util.Map<java.lang.String,Mustache.BlockSegment> blocks)protected static voidrestoreStartTag(java.lang.StringBuilder text, Mustache.Delims starts)protected static Template.Segment[]trim(Template.Segment[] segs, boolean top)
-
-
-
Field Detail
-
TEXT
protected static final int TEXT
- See Also:
- Constant Field Values
-
MATCHING_START
protected static final int MATCHING_START
- See Also:
- Constant Field Values
-
MATCHING_END
protected static final int MATCHING_END
- See Also:
- Constant Field Values
-
TAG
protected static final int TAG
- See Also:
- Constant Field Values
-
NO_CHAR
protected static final char NO_CHAR
Used when we have only a single character delimiter.- See Also:
- Constant Field Values
-
FAILING_LOADER
protected static final Mustache.TemplateLoader FAILING_LOADER
-
DEFAULT_FORMATTER
protected static final Mustache.Formatter DEFAULT_FORMATTER
-
-
Method Detail
-
compiler
public static Mustache.Compiler compiler()
Returns a compiler that escapes HTML by default and does not use standards mode.
-
compile
protected static Template compile(java.io.Reader source, Mustache.Compiler compiler)
Compiles the supplied template into a repeatedly executable intermediate form.
-
trim
protected static Template.Segment[] trim(Template.Segment[] segs, boolean top)
-
indentSegs
static Template.Segment[] indentSegs(Template.Segment[] _segs, java.lang.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, java.util.Map<java.lang.String,Mustache.BlockSegment> blocks)
-
restoreStartTag
protected static void restoreStartTag(java.lang.StringBuilder text, Mustache.Delims starts)
-
allowsWhitespace
protected static boolean allowsWhitespace(char typeChar)
-
-