[stringtemplate-interest] StringTemplate extension ideas

Kunle Odutola Kunle_Odutola at hotmail.com
Mon May 1 17:25:24 PDT 2006


> Yep. Allowing my example to be re-written as:
>
>    $target(t=outer.Attrib:{outerAtrribute | This is an $outerAtrribute$})$

Unfortunately, this doesn't seem to extend to multiple attributes.

$target(t=A, B:{a, b | These are  outer atrribute $a$ and $b$})$


Unit test (currently fails with a parse error):

[Test] public void testApplyingMultipleAttributesToAnonTemplateArgument()
{
    string templates = ""
    + "group test;" + NL
    + "caller(blort, mort) ::= <<$target(item=blort,mort:{b,m |Hi, $b$ and
$m$.})$>>" + NL
    + "target(item) ::= << <b>$item$</b> >>" + NL;

    StringTemplateGroup group = new StringTemplateGroup(new
StringReader(templates));
    StringTemplate caller = group.GetInstanceOf("caller");
    caller.SetAttribute("blort", "Blort");
    caller.SetAttribute("mort", "Mort");
    string expecting = "Hi, Blort and Mort.";
    Assert.AreEqual(expecting, caller.ToString());
}


Kunle


More information about the stringtemplate-interest mailing list