/*
* now use the Runtime resource loader to get the template
*/
Template t = null;
try
{
if (!blockinput)
t = rsvc.getTemplate( arg, getInputEncoding(context) );
}
catch ( ResourceNotFoundException rnfe )
{
/*
* the arg wasn't found. Note it and throw
*/
rsvc.getLog().error("#parse(): cannot find template '" + arg +
"', called from template " +
context.getCurrentTemplateName() + " at (" +
getLine() + ", " + getColumn() + ")" );
throw rnfe;
}
catch ( ParseErrorException pee )
{
/*
* the arg was found, but didn't parse - syntax error
* note it and throw
*/
rsvc.getLog().error("#parse(): syntax error in #parse()-ed template '"
+ arg + "', called from template " +
context.getCurrentTemplateName() + " at (" +
getLine() + ", " + getColumn() + ")" );
throw pee;
}
/**
* pass through application level runtime exceptions
*/
catch( RuntimeException e )
{
throw e;
}
catch ( Exception e)
{
String msg = "#parse() : arg = " + arg + '.';
rsvc.getLog().error(msg, e);
throw new VelocityException(msg, e);
}
/**
* Add the template name to the macro libraries list
*/
List macroLibraries = context.getMacroLibraries();
/**
* if macroLibraries are not set create a new one
*/
if (macroLibraries == null)
{
macroLibraries = new ArrayList();
}
context.setMacroLibraries(macroLibraries);
macroLibraries.add(arg);
/*
* and render it
*/
try
{
if (!blockinput) {
context.pushCurrentTemplateName(arg);
((SimpleNode) t.getData()).render( context, writer );
}
}
/*
* if it's a MIE, it came from the render.... throw it...