velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aapo Laakkonen" <aapo.laakko...@giro.fi>
Subject Map support in VTL
Date Wed, 09 Oct 2002 22:41:24 GMT
Is it possibly to add map (java.util.Map) support to VTL. What I mean is
something similar as the current Collection (java.util.ArrayList)
support:

#set($list = [ "one", "two", "three" ])

What I would like to see is Map (java.util.HashMap) support like the
following:

#set($map = { "one"=1, "two"=2, "three"=3 })

Is this too much asked? I'm not sure about the syntax above, but
something similar. Currently I have to do something like this to
archieve the same results:

#set($map = $Global.map)
#set($map.one = 1)
#set($map.two = 2)
#set($map.three = 3)

It's fine, but not as compact as I would like it to be. Look for example
the following:

#set($list = [ { "firstname"="Aapo", "lastname"="laakkonen" }, "text" ]

Seems simple, but this is what I have to do right now:

#set($list = []) ## or #set($list = $Global.list) 

$list.add(0, $Global.map)
#set($map = $list.get(0))

#set($map.firstname = "Aapo")
#set($map.lastname = "Laakkonen")

$list.add(1, "text")

As you see in this simple example, this second approach requires much
more typing.

Kind Regards
Aapo Laakkonen


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