[stringtemplate-interest] Referense template in other file.
Andrew Melnichuk
andrew.melnichuk at gmail.com
Thu Apr 19 12:20:12 PDT 2007
Thanks Terence. I have solved this problem by creating base group, which
contains all shared templates i need and deriving from it.
I have another question.
Lets assume i have a simple group definition:
group simplegroup;
mypage(title, content) ::= <<
<html>
<title>$title$</title>
<body>
$content$
</body>
</html>
>>
Documentation says that i can set default value for the formal parameters of
template. So i could rewrite my template as:
mypage(title = "Default Page", content = "Default Content") ::= <<
.............
>>
But can i set other template, defined in the same group, as default value?
Something like this:
mypage(title = "Default Page", content = defaultContent()) ::= <<
.............
>>
defaultContent() ::= "Default Content"
I have tried this and got the error. However, i have tried to pass template
defined in derived group into referenced template defined in base group, as
argument and it works.
Sorry for plenty of questions :) I'm just evaluating ST# to use as view
engine in my projects, trying to learn it and understand what is the best
way to organize templates.
On 4/18/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>
>
> On Apr 16, 2007, at 3:29 AM, Andrew Melnichuk wrote:
>
> > Hi.
> >
> > I have a template group file 'basegroup.stg' and it contains
> > definition of simple template
> >
> > group basegroup;
> > page1() ::= "$sharedview/somecontent()$"
> >
> > There is a subdirectory called 'sharedview' which contains template
> > file 'somecontent.st' with simple content:
> >
> > <p>Some_content_to_show</ p>
> >
> > I'm trying to load tempalte group and display 'page1' template, and
> > i'm awaiting that it displays content from referenced tempalte as
> > well, but i have an error:
>
> Hi Andrew,
>
> The issue is that ST assumes all stuff is in the group; I don't mix/
> max files and groups at the moment. My original co-designer, Tom
> Burns, and I are thinking of reworking this so groups just act like
> directories.
>
> Sorry for the hassle. You can just override the loadtemplate method
> in STG I think though.
>
> Ter
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>
--
Best regards,
Andrew Melnichuk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070419/031b2066/attachment.html
More information about the stringtemplate-interest
mailing list