velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aapo Laakkonen" <>
Subject RE: New Ideas (WAS: RE: Map support in VTL)
Date Thu, 10 Oct 2002 16:40:54 GMT
>> - Add dictionary (or map) support to VTL
>> (
>> - Add tuple support to VTL
>> (
> Velocity already has both of these: they're called
> Map and List, respectively. There's a parallel
> thread in this >list on creating the former,

Of course I knew that. I was one of those who started that thread. Map
creating utility works fine, but it is not as elegant as is could be
when it is added directly to Velocity.

> and VTL already supports creating the latter.
> The only thing missing is that tuples are
> unmodifiable.

Yeah, and that separates tuples from lists.

> If you want that, just add a Java method like,

I know I can add this and that, but my intent was to add some core
functionality to the Velocity itself. Yeah, you all bark that it is
bloat, but there are also several people (including me) that think that
maps should be added as core VTL syntax (and whitespace gobbling). Why
in first place there is support for lists? And why not for maps? Why
there is directives like #foreach or #if? You can do them just fine with
Java utility classes. I'm just questioning why maps cannot be added to


#set($map = { "fname": "Aapo", "lname": "Laakkonen", "age": 24 })

Or even like this:

#set($fields = [ { "title": "Username", "type": "text" }, { "title":
"Password", "type": "password" } ])

Then you could do something like this:

#foreach($field in $fields)

	$field.title: <input name="$field.title" type="$field.type"
/><br />


For me it looks damn elegant, but yes, it is possible to do it with
$util.buildMap() or similar, but I like the above approach more. Then we
could have #strip directive that is used like this:

		Hello World!

And this is stripped to something like this:

<td>Hello World!</td>

> if you want Python, you know where to find it.

I knew that! ... Have you anything against map support, and can you tell
me what? And if I want python I'd rather go with CheetahTemplate

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message