Modifier and Type | Field and Description |
---|---|
protected Map<String,Expression> |
attributes |
protected Map<String,Emitter> |
blocks |
protected CompilationContext |
compilationContext |
protected TagHandler |
parentHandler |
protected parsii.tokenizer.Position |
startOfTag |
protected String |
tagName |
Constructor and Description |
---|
TagHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addBlock(String name,
Emitter body)
Adds a block of emitters being passed to the template.
|
abstract void |
apply(CompositeEmitter targetBlock)
Invoked when the tag is completely parsedand can be applied to the target block.
|
void |
beforeBody()
Invoked once when all attributes are parsed but before the body is compiled.
|
Expression |
getAttribute(String name)
Fetches the attribute with the given name.
|
Emitter |
getBlock(String name)
Fetches a block passed to the tag
|
CompilationContext |
getCompilationContext()
Returns the context of the current compilation.
|
sirius.kernel.commons.Value |
getConstantAttribute(String name)
Fetches the attribute with the given name, expecting that a constant value is present.
|
Class<?> |
getExpectedAttributeType(String name)
Returns the expected type for the given attribute.
|
TagHandler |
getParentHandler()
If a tag is defined within another tag, this will return the outer (parent) tag.
|
parsii.tokenizer.Position |
getStartOfTag()
Returns the position where the tag was defined.
|
String |
getTagName()
Returns the name of the tag being handled.
|
void |
setAttribute(String name,
Expression expression)
Specifies an attribute.
|
void |
setCompilationContext(CompilationContext context)
Specifies the compilation context.
|
void |
setParentHandler(TagHandler parentHandler)
Specifies the handler of the enclosing tag.
|
void |
setStartOfTag(parsii.tokenizer.Position startOfTag)
Specifies the position where the tag was defined.
|
void |
setTagName(String tagName)
Specifies the name of the tag being handled.
|
protected parsii.tokenizer.Position startOfTag
protected CompilationContext compilationContext
protected TagHandler parentHandler
protected String tagName
protected Map<String,Expression> attributes
public void addBlock(String name, Emitter body)
name
- the name of the blockbody
- the emitter representing the blockBlockTag
@Nullable public Emitter getBlock(@Nonnull String name)
name
- the name of the block to fetchpublic Expression getAttribute(String name)
name
- the name of the attribute to fetch@Nonnull public sirius.kernel.commons.Value getConstantAttribute(@Nonnull String name)
name
- the name of the attribute to fetchValue
. If the attribute is missing, an empty value will be
returned.public Class<?> getExpectedAttributeType(String name)
name
- the name of the attributeExpression
to signal that any expression is
accepted or null to indicate that the parameter is unexpected.public void setAttribute(String name, Expression expression)
name
- the name of the attributeexpression
- the expression for the attributepublic parsii.tokenizer.Position getStartOfTag()
public void setStartOfTag(parsii.tokenizer.Position startOfTag)
startOfTag
- the position where the tag started.public CompilationContext getCompilationContext()
public void setCompilationContext(CompilationContext context)
context
- the current compilation context@Nullable public TagHandler getParentHandler()
public void setParentHandler(TagHandler parentHandler)
parentHandler
- the handler of the enclosing tagpublic String getTagName()
public void setTagName(String tagName)
tagName
- the name of the tagpublic void beforeBody()
public abstract void apply(CompositeEmitter targetBlock)
targetBlock
- the outer block to which the output can be appendedCopyright © 2018. All rights reserved.