Module com.samskivert.jmustache
Package com.samskivert.mustache
Class Mustache.ParentTemplateSegment
- java.lang.Object
-
- com.samskivert.mustache.Template.Segment
-
- com.samskivert.mustache.Mustache.NamedSegment
-
- com.samskivert.mustache.Mustache.AbstractPartialSegment
-
- com.samskivert.mustache.Mustache.ParentTemplateSegment
-
- All Implemented Interfaces:
Mustache.BlockReplaceable
,Mustache.StandaloneSection
- Enclosing class:
- Mustache
protected static class Mustache.ParentTemplateSegment extends Mustache.AbstractPartialSegment implements Mustache.StandaloneSection
A segment that loads and executes a parent template by spec called inheritance.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,Mustache.BlockSegment>
_blocks
protected Template.Segment[]
_segs
protected boolean
_standaloneEnd
protected boolean
_standaloneStart
-
Fields inherited from class com.samskivert.mustache.Mustache.AbstractPartialSegment
_comp, _indent
-
Fields inherited from class com.samskivert.mustache.Mustache.NamedSegment
_line, _name
-
-
Constructor Summary
Constructors Modifier Constructor Description ParentTemplateSegment(Mustache.Compiler compiler, java.lang.String name, Template.Segment[] segs, int line)
private
ParentTemplateSegment(Mustache.Compiler compiler, java.lang.String name, Template.Segment[] segs, int line, java.lang.String indent)
private
ParentTemplateSegment(Mustache.ParentTemplateSegment original, Template.Segment[] segs, java.lang.String indent, java.util.Map<java.lang.String,Mustache.BlockSegment> blocks)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Template
_loadTemplate()
Template.Segment[]
_segs()
void
decompile(Mustache.Delims delims, java.lang.StringBuilder into)
protected Mustache.ParentTemplateSegment
indent(java.lang.String indent, boolean first, boolean last)
Recursively indent by the parameter indent.boolean
isStandalone()
Whether or not the segment is standalone.boolean
isStandaloneEnd()
boolean
isStandaloneStart()
boolean
lastTrailsBlank()
private static Template.Segment[]
removeNonBlocks(Template.Segment[] segs)
Mustache.ParentTemplateSegment
replaceBlocks(java.util.Map<java.lang.String,Mustache.BlockSegment> blocks)
void
standaloneEnd(boolean standaloneEnd)
void
standaloneStart(boolean standaloneStart)
java.lang.String
toString()
void
trimLastBlank()
void
visit(Mustache.Visitor visitor)
-
Methods inherited from class com.samskivert.mustache.Mustache.AbstractPartialSegment
execute, getTemplate
-
Methods inherited from class com.samskivert.mustache.Template.Segment
write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.samskivert.mustache.Mustache.StandaloneSection
firstLeadsBlank, trimFirstBlank
-
-
-
-
Field Detail
-
_segs
protected final Template.Segment[] _segs
-
_standaloneStart
protected boolean _standaloneStart
-
_standaloneEnd
protected boolean _standaloneEnd
-
_blocks
protected final java.util.Map<java.lang.String,Mustache.BlockSegment> _blocks
-
-
Constructor Detail
-
ParentTemplateSegment
public ParentTemplateSegment(Mustache.Compiler compiler, java.lang.String name, Template.Segment[] segs, int line)
-
ParentTemplateSegment
private ParentTemplateSegment(Mustache.Compiler compiler, java.lang.String name, Template.Segment[] segs, int line, java.lang.String indent)
-
ParentTemplateSegment
private ParentTemplateSegment(Mustache.ParentTemplateSegment original, Template.Segment[] segs, java.lang.String indent, java.util.Map<java.lang.String,Mustache.BlockSegment> blocks)
-
-
Method Detail
-
removeNonBlocks
private static Template.Segment[] removeNonBlocks(Template.Segment[] segs)
-
decompile
public void decompile(Mustache.Delims delims, java.lang.StringBuilder into)
- Specified by:
decompile
in classTemplate.Segment
-
visit
public void visit(Mustache.Visitor visitor)
- Specified by:
visit
in classTemplate.Segment
-
indent
protected Mustache.ParentTemplateSegment indent(java.lang.String indent, boolean first, boolean last)
Description copied from class:Template.Segment
Recursively indent by the parameter indent.- Specified by:
indent
in classTemplate.Segment
- Parameters:
indent
- should be space characters that are not\n
.first
- append indent to the first line (regardless if it has a\n
or not).last
- append indent on the last\n
that has no text after it.- Returns:
- a newly created segment or the same segment if nothing changed.
-
_loadTemplate
protected Template _loadTemplate()
- Overrides:
_loadTemplate
in classMustache.AbstractPartialSegment
-
lastTrailsBlank
public boolean lastTrailsBlank()
- Specified by:
lastTrailsBlank
in interfaceMustache.StandaloneSection
-
trimLastBlank
public void trimLastBlank()
- Specified by:
trimLastBlank
in interfaceMustache.StandaloneSection
-
replaceBlocks
public Mustache.ParentTemplateSegment replaceBlocks(java.util.Map<java.lang.String,Mustache.BlockSegment> blocks)
- Specified by:
replaceBlocks
in interfaceMustache.BlockReplaceable
-
_segs
public Template.Segment[] _segs()
- Specified by:
_segs
in interfaceMustache.StandaloneSection
-
isStandalone
public boolean isStandalone()
Description copied from class:Template.Segment
Whether or not the segment is standalone. The definition of standalone is defined by the mustache spec. String and variable tags are never standalone. For blocks this is based on the closing tag. Oncetrim
is called, standalone tags are determined so that proper (re)indentation will work without reparsing the template.- Specified by:
isStandalone
in classMustache.AbstractPartialSegment
- Returns:
- true if the tag is standalone.
-
isStandaloneStart
public boolean isStandaloneStart()
- Specified by:
isStandaloneStart
in interfaceMustache.StandaloneSection
-
isStandaloneEnd
public boolean isStandaloneEnd()
- Specified by:
isStandaloneEnd
in interfaceMustache.StandaloneSection
-
standaloneStart
public void standaloneStart(boolean standaloneStart)
- Specified by:
standaloneStart
in interfaceMustache.StandaloneSection
-
standaloneEnd
public void standaloneEnd(boolean standaloneEnd)
- Specified by:
standaloneEnd
in interfaceMustache.StandaloneSection
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-