velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aapo Laakkonen" <aapo.laakko...@giro.fi>
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
>> (http://diveintopython.org/odbchelper_dict.html)
>> - Add tuple support to VTL
>> (http://diveintopython.org/odbchelper_tuple.html)
>
> 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
VTL?

READ:

#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 />

#end

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:

<table>
<tr>
	#strip
	<td>
		Hello World!
	</td>
	#end
</tr>
</table>

And this is stripped to something like this:

<table>
<tr>
<td>Hello World!</td>
</tr>
</table>

> 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
(http://www.cheetahtemplate.org/).


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message