[stringtemplate-interest] Set up template attributes with external method call
Ben Corne
ben.corne at gmail.com
Sat Sep 3 03:06:02 PDT 2011
Hi!
I'm rather new to StringTemplate but I'm wondering if there's a way to do
the following inside a template: call methods on an attribute value with
arguments that are more attribute values.
I've read that allowing this is not promoting the strict separation of view
and model.
This is my context: I have the output of a programming language
documentation tool. It is a tree-like construction where objects, methods
(and more, left out for simplicity) can be nested in any level of the tree.
I start at the root, this is a template file called file.st.
file.st includes begin.st (a file is a statementlist)
begin.st has a set of objects and functions
an object is also a statementlist and needs to include begin aswell.
a function is a leave of the tree.
I know that for the initial StringTemplate you can set up attributes from
the pure java world. However, once inside the first template, you have to
initialize attributes for subtemplates in the StringTemplate world. I don't
want to put this burdon on template writers for my tool so I wanted to
provide an method that does this for them.
=> For each type of documented concept I have a StringTemplate file and a
method "run<File|Function|Object>(concept)" that sets up the attribute
values given that concept.
Is there any way to acchieve this that doesn't mean having to make separate
dataclasses to represent the tree in a way that stringtemplate can visit it?
Or am I missing the big picture?
Kind regards,
Ben Corne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110903/0e8e7054/attachment.html
More information about the stringtemplate-interest
mailing list