[stringtemplate-interest] Region Syntax

Terence Parr parrt at cs.usfca.edu
Tue Sep 25 16:40:36 PDT 2007


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




More information about the stringtemplate-interest mailing list