[stringtemplate-interest] deployment question
John Snyders
jjsnyders at rcn.com
Thu Aug 23 12:02:59 PDT 2007
What I find interesting about this scenario is that one template language is being used to generate the text of another template language. This can be done as long as the syntax of one language doesn't get confused by another. I think Velocity uses $ so you will need to use the < > delimiters in ST.
I think there is a use case (Greg gives a real world example of it) for a template language to be able to easily generate templates in it's own language.
Another way to look at this is as multiple passes over the same template or processing the templates in different modes. Just the template expressions intended for that pass/mode should be executed.
You can escape the template delimiter with \$ but this gets messy especially with more than one pass. The third pass would use \\\$.
A nice thing about ST is that it can use two different sets of delimiters < > or $ $ so you can change the parser between passes.
This may be all that is ever needed but I wonder if being able to target rules to specific modes would be useful. For example:
Here is attribute foo from mode 1 $/mode1/foo$ and here is bar from mode 2 $/mode2/bar$
Running ST with mode == "mode1" would produce:
Here is attribute foo from mode 1 value-of-foo and here is bar from mode 2 $/mode2/bar$
-John
---- Original message ----
>Date: Sat, 18 Aug 2007 19:15:49 -0700
>From: "Colin Bean" <ccbean at gmail.com>
>Subject: Re: [stringtemplate-interest] deployment question
>To: "Greg Parker" <greg.parker at brovada.com>
>Cc: stringtemplate-interest at antlr.org
>
>Take a look at this article by John Snyders:
>
>http://hardlikesoftware.com/weblog/2007/01/15/i18n-with-stringtemplate/
>
>Should work for what you're doing.
>
>-Colin
>
>
>
>On 8/18/07, Greg Parker <greg.parker at brovada.com> wrote:
>> Just curious to see if StringTemplate can solve a particular deployment
>> requirement I have on a project. Currently we host a repository full of
>> Velocity templates that our clients download and use within software
>> installed on their computers. We are now getting ready to add
>> muti-language support to these templates. I would like to maintain one
>> copy of each template and simply externalize all the language elements
>> into resource files. At deployment time I would like to preprocess the
>> templates into one repository per supported language. So all we have to
>> do is maintain one template, and one resource file per language. The
>> problem is that the templates are velocity templates. If I use velocity
>> to preprocess the templates to add the language support, I will also
>> inadvertently affect the template variables that have nothing to do with
>> language support. I just thought I would post this question on the off
>> chance that StringTemplate has some type of facility for this, or that
>> someone might have a solution.
>>
>> Thanks
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>>
>_______________________________________________
>stringtemplate-interest mailing list
>stringtemplate-interest at antlr.org
>http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list