[stringtemplate-interest] Templates that get another templates as arguments?
Дмитрий Васильев
dmitry.vasil at gmail.com
Sun Jun 26 09:14:57 PDT 2011
Consider the following example. I have a template that greets my friends:
greet()::=<<
<hello("Bob")>
<hello("John")>
<hello("Kate")>
<hello("Barbara")>
>>
hello(name)::=<<
Hello, <name>!
>>
Sometimes I want print their names in bold:
hello(name)::=<<
Hello, [b]<name>[/b]!
>>
Sometimes I want to prepend their names with the word "dear":
hello(name)::=<<
Hello, dear <name>!
>>
Generally, I want to pass a template for handling various cases as an
argument to template 'greet()'. I want to be able to do something like this:
greet(processName)::=<<
<hello("Bob")>
<hello("John")>
<hello("Kate")>
<hello("Barbara")>
>>
hello(name)::=<<
Hello, <processName(name)>
>>
bold(text)::=<<
[b]<text>[/b]
>>
dear(name)::=<<
dear <name>
>>
greet_in_bold()::=<<
<greet(processName=bold)>
>>
greet_dear()::=<<
<greet(processName=dear)>
>>
But I can't find how I can do something similar with StringTemplate. Do I
miss something obvious?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110626/7b262c50/attachment.html
More information about the stringtemplate-interest
mailing list