[stringtemplate-interest] Suggestions: Map parameters and Template-identity checks
Barrie Treloar
baerrach at gmail.com
Mon Dec 7 14:25:02 PST 2009
On Tue, Dec 8, 2009 at 7:10 AM, Swapnil Kashikar
<swapnil.kashikar at gmail.com> wrote:
> Hi Ter,
>
>> > To solve this I would suggest that maps be allowed to take more than one
>> > parameter. The first one can be designated as the 'key' and the rest can
>> > function like the regular parameters of a named-template.
>>
>> Hmm...I think the easiest way to handle this is to use the default
>> parameter. I should have done this in the book. basically let's say we have
>> a map that looks like this ( or dictionary as I'm calling it now):
>>
>> m ::= [ "foo" : {*<it>*} ]
>>
>> Then we can access that with <m.foo> but a how do we set "it"? perhaps,
>> <"dog":m.foo> ???
>
> Can you explain how to use it in this example, which shows what I do today
> and also my suggested syntax:
>
> //How I define map today
> m ::=
> [ "full" : {My name is: <firstname> <middlename> <lastname>},
> "first_last" : {My name is: <firstname> <lastname>},
> "last_first" : {My name is: <lastname>, <firstname>}
> ]
Why do you want the template to do this?
I think Terence's recommendation that this should be in the model
makes more sense.
Your model should define "full", "first_last" and "last_first" and
then you can reference these values in your template when you need
them.
More information about the stringtemplate-interest
mailing list