|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.template.Template
sunlabs.brazil.template.MacroTemplate (view source)
public class MacroTemplate
Template class for defining macros. Macros are defined by:
<definemacro name=macro-name [global=true|false]> .... </definemacro>The text (.....) has any leading and trailing whitespace removed.
To expand a macro: <macro-name name1=value1 ...>.
All ${...} constructs in The previously saved macro body
are processed, and the result replaces the macro-name
tag. Attributes provided in the macro name override any variables
that exist in the request properties.
Several special variables are supplied, as if they were specified as attributes, but only if otherwise not already defined either as an attribute or as a property,
isSingleton
args
Templates are processed by reading the input "document" a tag
at a time to generate the output document.
By default, the macro body is pushed onto the not-yet-processed
input stream; any tags contained in the macro body will be processed.
If the defer
attribute is present,
the macro body is placed onto the output stream instead.
This is more efficient, but requires an additional filter pass
if the body of the macro contains tags that need to be processed
in the current context.
This is an experiment. The current implementation is flawed, although it is less flawed than the previous one.
NOTE:
The init files in previous releases used java properties format
files to define macros; This version uses xml templates. See "main"
below for a utility to convert the old properties format files to
the new format.
Field Summary | |
---|---|
Properties |
macroTable
|
Fields inherited from class sunlabs.brazil.template.Template |
---|
debug |
Constructor Summary | |
---|---|
MacroTemplate()
|
Method Summary | |
---|---|
void |
defaultTag(RewriteContext hr)
Run the macro, push formal parameters on the stack first. |
boolean |
init(RewriteContext hr)
Read in the inital macros, if needed. |
static void |
main(String[] args)
Convert stdin properties format macro definition files to the new template style. |
static String |
snarfTillClose(LexML lex,
String tag)
Grab all the markup starting from the current tag until the matching closing tag, and return as a string. |
void |
tag_definemacro(RewriteContext hr)
Define a new macro. |
Methods inherited from class sunlabs.brazil.template.Template |
---|
done |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Properties macroTable
Constructor Detail |
---|
public MacroTemplate()
Method Detail |
---|
public boolean init(RewriteContext hr)
init
in interface TemplateInterface
init
in class Template
public static String snarfTillClose(LexML lex, String tag)
public void tag_definemacro(RewriteContext hr)
<name ...>
will be replaced by the contents of the macro
named "name".
<definemacro name=nnn [global=true|false]>...</definemacro>
<definemacro nnn>
is a shortcut for
<definemacro name=nnn>
public void defaultTag(RewriteContext hr)
If the parameter defer=true
is present, the text of the macro is output
directly, with only ${..} substitutions performed. Otherwise, the markup in the macro
body is rescanned and processed.
public static void main(String[] args) throws IOException
IOException
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |