public class BlockMacro extends Block
The macro can then refer to the passed body AST. This directive can be used as a "decorator". Body AST can contain any valid Velocity syntax. An example:
#set($foobar = "yeah!") #macro(strong $txt) <strong>$bodyContent</strong> $txt #end #@strong($foobar) <u>This text is underlined and bold</u> #endWill print:
<strong><u>This text is underlined and bold<u></strong> yeah!bodyContent reference name is configurable (see velocity.properties).
Block.ReferenceBLOCK, LINE| 构造器和说明 |
|---|
BlockMacro(java.lang.String name) |
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.String |
getName()
Return the name of this directive.
|
java.lang.String |
getScopeName()
Override to use the macro name, since it is within an
#@myMacro() ...
|
void |
init(RuntimeServices rs,
InternalContextAdapter context,
Node node)
Initializes the directive.
|
boolean |
render(InternalContextAdapter context,
java.io.Writer writer,
Node node)
Renders content using the selected macro and the passed AST body.
|
getColumn, getLine, getTemplateName, isScopeProvided, makeScope, postRender, preRender, setLocation, setLocationpublic java.lang.String getName()
Directivepublic java.lang.String getScopeName()
getScopeName 在类中 Directivepublic void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException
init 在类中 Blockrs - context - node - TemplateInitExceptionpublic boolean render(InternalContextAdapter context, java.io.Writer writer, Node node) throws java.io.IOException