[stringtemplate-interest] Attributes in derived templates.

Andrew Melnichuk andrew.melnichuk at gmail.com
Fri Apr 20 01:56:04 PDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070420/cef55ac1/attachment.html 


More information about the stringtemplate-interest mailing list