[stringtemplate-interest] Region Syntax
Andrew Hallock
andrew.hallock at gmail.com
Tue Sep 25 17:52:52 PDT 2007
Hi Terrance,
> Set @page_title in a subgroup. Joy shall be yours. :)
So close, but no joy was had :)
I had a subgroup overriding the layout regions as you mention - works fine -
but I want to add attributes that are not part of the formal argument list
on the parent group, since the subgroup overriding region has its own
context and its own idea of what it wants to override with.
group layout;
main_layout() ::= <<
<html>
<head>
<title>
$@page_title()$
</title>
</head>
<body>
$@child_content()$
</body>
</html>
>>
I want to override the child_content region in a subgroup, but also supply
new attributes based on what page the user is requesting.
In code, I use StringTemplate.FormalArguments.Add() to get around this, but
I don't know if this is correct behavior.
Appreciate your feedback.
Thanks,
Andrew
On 9/25/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>
>
> On Sep 25, 2007, at 10:45 AM, Andrew Hallock 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.
>
> hi :)
>
> You cannot "set" anything from a template.
>
> > 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.
>
> Can't. that's a side-effect. Only groups can override and hence set
> a region. Just like classes and methods.
>
> Set @page_title in a subgroup. Joy shall be yours. :)
> Ter
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070925/72857e22/attachment.html
More information about the stringtemplate-interest
mailing list