public class RichTemplate extends BasicTemplate
Template
supporting the following tags.
Tags:
${count iterable-key}
replaces the tag with
the number of iterations.${if key=value}
processes the block
only if the key equals the value.${if key!=value}
processes the
block only if the key doesn't equals the value.${if key=}
processes the block only if the
key has a value.${if-none key=}
processes the block
only if the key has no value.${for-each iterable-key}
processes the
block once per iteration. A segment of the iteration can be specified as
${for-each iterable-key;start;limit}
, where
start
is which iteration to start at, and limit
is
the maximum number of iterations to go through from there. They can be
literal numbers or keys. See below for special codes that can be used within
the for-each block.${if iterable-key}
processes the block once
only if there are iterations. If there are no iterations, then it does
not process the block.${if-one iterable-key}
processes the
block once only if there is exactly one iteration. If there are
no iterations, or more than one iteration, then it does not process the
block.${if-many iterable-key}
processes the
block once only if there are more than one iterations. If there
are no iterations, or only one iteration, then it does not process the block.
${if-none iterable-key}
processes
the block once only if there are no iterations. If there is even one
iteration, then it does not process the block.${if-first}
processes the block only if
this is the first iteration of the loop.${if-not-first}
processes the block
only if this is not the first iteration of the loop.${if-more}
processes the block only if
the outlying block has more iterations.${index-from-0}
replaces the tag with the
0-based number of the current iteration of the outlying loop.${index-from-1}
replaces the tag with the
1-based number of the current iteration of the outlying loop.TAG_IMPORT_BEGIN, TAG_IMPORT_BEGIN_LENGTH, TAG_IMPORT_END, TAG_IMPORT_END_LENGTH
Constructor and Description |
---|
RichTemplate(String content,
TemplateSource importTemplateSource) |
Modifier and Type | Method and Description |
---|---|
protected void |
cast(Chunk chunk,
Filler filler,
Appendable out,
boolean soft) |
protected Chunk |
parseTag(String tag) |
cast, getExternalHandler, getFormatter, getRequiredTags, setExternalHandler, setFormatter, softCast, streamCast, toString, transform
public RichTemplate(String content, TemplateSource importTemplateSource) throws ParseException, TemplateSourceException
protected Chunk parseTag(String tag) throws ParseException
parseTag
in class BasicTemplate
ParseException
protected void cast(Chunk chunk, Filler filler, Appendable out, boolean soft) throws CastException, IOException
cast
in class BasicTemplate
CastException
IOException
Copyright © 2009-2015 Three Crickets LLC.