public class RuntimeMacro extends Directive
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
badArgsErrorMsg
badArgsErrorMsg will be non null if the arguments to this macro
are deamed bad at init time, see the init method.
|
private java.lang.String |
literal
Literal text of the macro
|
private java.lang.String |
macroName
Name of the macro
|
private Node |
node
Node of the macro call
|
protected boolean |
strictRef
Indicates if we are running in strict reference mode.
|
BLOCK, LINE
Constructor and Description |
---|
RuntimeMacro() |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
getLiteral()
It is probably quite rare that we need to render the macro literal
but since we won't keep the tokens in memory, we need to calculate it
at parsing time.
|
java.lang.String |
getName()
Return name of this Velocimacro.
|
java.lang.String |
getScopeName()
Override to always return "macro".
|
int |
getType()
Velocimacros are always LINE
type directives.
|
void |
init(RuntimeServices rs,
java.lang.String name,
InternalContextAdapter context,
Node node)
Initialize the Runtime macro.
|
boolean |
render(InternalContextAdapter context,
java.io.Writer writer,
Node node)
Velocimacro implementation is not known at the init time.
|
boolean |
render(InternalContextAdapter context,
java.io.Writer writer,
Node node,
Renderable body)
This method is used with BlockMacro when we want to render a macro with a body AST.
|
checkArgs, getColumn, getLine, getTemplate, getTemplateName, init, isScopeProvided, makeScope, postRender, preRender, setLocation, setLocation
private java.lang.String macroName
private java.lang.String literal
private Node node
protected boolean strictRef
private java.lang.String badArgsErrorMsg
public java.lang.String getName()
public java.lang.String getScopeName()
getScopeName
in class Directive
public int getType()
public void init(RuntimeServices rs, java.lang.String name, InternalContextAdapter context, Node node)
rs
- runtime servicesname
- macro namecontext
- InternalContextAdapternode
- node containing the macro callprivate java.lang.String getLiteral()
public boolean render(InternalContextAdapter context, java.io.Writer writer, Node node) throws java.io.IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException
render
in class Directive
context
- writer
- node
- java.io.IOException
ResourceNotFoundException
ParseErrorException
MethodInvocationException
public boolean render(InternalContextAdapter context, java.io.Writer writer, Node node, Renderable body) throws java.io.IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException
context
- writer
- node
- body
- AST block that was enclosed in the macro body.java.io.IOException
ResourceNotFoundException
ParseErrorException
MethodInvocationException