[stringtemplate-interest] Attributes in derived templates.
Terence Parr
parrt at cs.usfca.edu
Sun Apr 22 17:30:50 PDT 2007
Hi. it seems to me to you are not passing anything to template
someContent, therefore "$attr$" will have no value and be empty.
sorry for the delay and my absence on the string template list. I
will be picking up string template development during the summer. I
am almost done with version 3 release of ANTLR. The book will be
printed in early May, which includes examples using ANTLR and ST for
source is code generation!
Ter
On Apr 20, 2007, at 1:56 AM, Andrew Melnichuk wrote:
> Hi all.
>
> I have a simple base group defined:
> -------------
> group basepage;
>
> page() ::= <<
> <html>
> $someContent()$
> </html>
> >>
>
> someContent() ::= "Base Content"
> -----------
>
> I also have derived group defined, which overrides content template:
>
> -----------
> group concretepage : basepage;
>
> someContent(attr) ::= "$attr$"
> -----------
>
> I want to render a page, and i want it uses a derived content
> template, with passed attribute's value, so in code i'm doing next:
>
> StringTemplateGroup.RegisterDefaultLexer(typeof
> (DefaultTemplateLexer));
> StringTemplateGroup.RegisterGroupLoader(loader);
>
> StringTemplateGroup stg = StringTemplateGroup.LoadGroup
> ("concretepage");
>
> StringTemplate stPage = stg.GetInstanceOf ("page");
> StringTemplate stContent = stg.GetInstanceOf
> ("someContent");
> stContent.SetAttribute("attr", "Derrived Content");
>
> Console.WriteLine (stPage.ToString());
>
> I'm expecting that derived template will get attributes its value,
> but it does not. So, result i'm having is "<html></html>", but
> expected "<html>Derrived Content</html>".
>
> Am i doing something wrong?
> --
> Best regards,
> Andrew Melnichuk
> _______________________________________________
> 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