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

Barrie Treloar baerrach at gmail.com
Wed Apr 20 04:40:50 PDT 2011


On Wed, Apr 20, 2011 at 5:14 PM, Udo Borkowski <ub at abego-software.de> wrote:
> Hi Barrie,
> you can simplify your templates by using both the "template group directory"
> and "template group file" feature of ST4.
> ST4 allows you to create template groups in two ways:
> - create a directory (the "template group directory") and put all template
> files (extension ".st") of that group into the directory.
> - create a template group file (extension ".stg") containing all template
> definitions of that group (for syntax
> see http://www.antlr.org/wiki/display/ST4/Group+file+syntax)
[del]
> mytemplate.stg
> ----------------------
> import "common"
> mytemplate() ::= <<
> <HelloWorld()>
[del]
> You may also want to have a look at chapter "Import statements"
> in http://www.antlr.org/wiki/display/ST4/Group+file+syntax
> Hope this helps.

Yes, thanks.
I think its just my obsessive desire to have things cleanly separated
that makes me reluctant to have an *.stg file with template
definitions in it.
I'd rather them in their own *.st files.

But without the *.stg file there is no way to import stuff properly.
I almost wish STGroupDir had a magic file, like ".stg", that you could
place Group file syntax into (as STGroupDir doesn't have the same
features as STGroupFile does otherwise).
The problem then is that the STGroupDir has to treat the entire
directory as being part of the group, when it may not make sense to do
so.

I'll start use *.stg files and see how I go.

Thanks


More information about the stringtemplate-interest mailing list