}
}
if (provideScope)
{
ica.put(scopeName, new Scope(this, ica.get(scopeName)));
}
try
{
ica.pushCurrentTemplateName( name );
ica.setCurrentResource( this );
( (SimpleNode) data ).render( ica, writer);
}
catch (StopCommand stop)
{
if (!stop.isFor(this))
{
throw stop;
}
else if (Logger.isDebugEnabled(this.getClass()))
{
Logger.debug(this,stop.getMessage());
}
}
catch (IOException e)
{
throw new VelocityException("IO Error rendering template '"+ name + "'", e);
}
finally
{
/*
* lets make sure that we always clean up the context
*/
ica.popCurrentTemplateName();
ica.setCurrentResource( null );
if (provideScope)
{
Object obj = ica.get(scopeName);
if (obj instanceof Scope)
{
Scope scope = (Scope)obj;
if (scope.getParent() != null)
{
ica.put(scopeName, scope.getParent());
}
else if (scope.getReplaced() != null)
{
ica.put(scopeName, scope.getReplaced());
}
else
{
ica.remove(scopeName);
}