[stringtemplate-interest] ST4: Directory STGroups, common templates, relative template names?

Udo Borkowski ub at abego-software.de
Thu Apr 21 00:10:27 PDT 2011


> So the advice really is "All entry points into ST should be via a STGroupFile"
> Even if you have a simple template, it would still be beneficial to
> use a STGroupFile so that when the template gets enhanced you already
> have all the features you need.  Only the most basic templates should
> just be a template file.  All support templates (i.e. never called
> directly from code) can be basic templates.
> STGroupDir features should only be used from within a STGroupFile,
> dont try to use STGroupDir as an entry point for into ST.

A very nice summary of the way group files, group directories and "basic" templates should be used. Looks very reasonable to me. I guess something like this should go into the ST4 documentation. It gives developers a better idea, how to organize their templates.

Personally I am now only using ".stg" files. I first started with simple template files, but ran into similar issues like you. I guess it highly depends on the stuff you are doing but for me GroupFiles give me most flexibility, especially when a project evolves over time.


Some time ago we already noticed the asymmetry between group files and group directories when discussing different topics (e.g. delimiter character specification in a group). It was suggested to add a special file in the group directory to support these features both in the file and directory variant. (http://www.antlr.org/pipermail/stringtemplate-interest/2011-January/003016.html) You also suggested something similar in a recent mail regarding the "imports" in group directories. Maybe we should restart the discussion of such a special file, as we now have more cases that could be covered this way (delimiters, imports, encoding). 

Udo




On 21.04.2011, at 03:00, Barrie Treloar wrote:

> I've been thinking about this some more.
> 
> So the advice really is "All entry points into ST should be via a STGroupFile"
> Even if you have a simple template, it would still be beneficial to
> use a STGroupFile so that when the template gets enhanced you already
> have all the features you need.  Only the most basic templates should
> just be a template file.  All support templates (i.e. never called
> directly from code) can be basic templates.
> STGroupDir features should only be used from within a STGroupFile,
> dont try to use STGroupDir as an entry point for into ST.
> 
> Admittedly I read the ST 3 documentation a long time ago, and I've
> only re-read the ST 4 documentation since then.
> Is this advice sound?
> Would it be worthwhile adding something like that to the wiki pages?
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list