You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steve O'Hara <so...@pivotal-solutions.co.uk> on 2006/03/24 16:30:23 UTC

Read default values from template

This is similar to a previous post about collecting variables from a
template.

What I want to do, is efficiently retrieve default values for simple
assignments that a user may have made within a template i.e. I want to
collect all the values for the following types of assignments;

     #set($default_columns="steve,dave,pete")

At the moment I'm doing a merge on the template into an empty
StringWriter and reading the values from the context, which works
perfectly e.g.
     
     objTemplate.merge(objcontext, new StringWriter())

This is OK but it does seem to be a little expensive in time - I'm
wondering if someone can point me in the right direction for traversing
the parser node tree.

I've tried some code that loops though the nodes (taken from the
TemplateTool code) and I see that there is a very interesting node
method called render(), but I'm starting to wonder if this is going to
reap any real benefit.

Has anyone got any experience with this sort of thing?

Thanks,

Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org