[stringtemplate-interest] Set up template attributes with external method call

Collin Fagan collin.fagan at gmail.com
Sat Sep 3 05:18:46 PDT 2011


Hi Ben,

You might want to look at writing model adapters to "add" the properties you
want to the object hierarchy you are stuck with.

I have some examples on the strum page.

http://sourceforge.net/apps/mediawiki/project-strum/index.php?title=Main_Page

The basic idea is "hey ST when you see this attribute on this class do *
this".
*
I hope this helps,

Collin


On Sat, Sep 3, 2011 at 5:06 AM, Ben Corne <ben.corne at gmail.com> wrote:

> 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
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110903/a060b4f1/attachment.html 


More information about the stringtemplate-interest mailing list