[stringtemplate-interest] Region Syntax
Andrew Hallock
andrew.hallock at gmail.com
Tue Sep 25 14:09:03 PDT 2007
I got this to work with the following, but run into a problem with group
formal args:
Layout.stg:
group layout;
main_layout() ::= <<
<html>
<head>
<title>
$@page_title()$
</title>
</head>
<body>
$@child_content()$
</body>
</html>
>>
Then the derived group, home.stg
group home : layout;
@main_layout.page_title() ::= "Homepage"
@main_layout.child_content() ::= "<h1>Welcome, $name$</h1>"
Setup code:
...
StringTemplate st = subgroup.GetInstanceOf("main_layout"); //subgroup
holding the group "home"
This line throws an exception because of formal arg checking :
st.SetAttribute("name", "Andrew");
Is there a way to set attributes in the "child_content" region? The base
group file can't know all the possible attributes that might be needed for
@main_layout.child_content()
Thanks,
Andrew
On 9/25/07, Andrew Hallock <andrew.hallock at gmail.com> wrote:
>
> Nevermind...I think I can get it to work with group inheritance instead of
> simple templates.
>
> On 9/25/07, Andrew Hallock < andrew.hallock at gmail.com> wrote:
> >
> > I can't seem to get the syntax right for Template Regions:
> >
> > I need to set an attribute in an outer template (specifically, setting
> > an HTML document's title element) from within a subtemplate.
> >
> > Say, for simplicity, I have a file " layout.st" which can compromise
> > other page templates.
> >
> > layout.st would look like:
> > <html>
> > <title>
> > $@page_title()$
> > </title>
> > <body>
> > $(content_template_name)()$
> > </body>
> > </html>
> >
> > How would you use the Template Region mechanism to set the layout's
> > title region from within the child template? It would be the equivalent of
> > Django's template inheritance.
> >
> > Regards,
> > Andrew
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070925/48e143f7/attachment.html
More information about the stringtemplate-interest
mailing list