velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Smith <Paul.Sm...@lawlex.com.au>
Subject RE: Map support in VTL
Date Wed, 09 Oct 2002 23:52:08 GMT
> A slight variation to the above is to use the array syntax like this:
>      #set( $myMap = $MapFactory.build(["one=1", "two=2", "three=3"]) )
> 
> The build method accepts an ArrayList and then iterates over it 
> splitting each element on the first "=" putting the key and associated 
> value into a HashMap.  Ought to be rather easy to implement if you 
> assume all values are Strings.  No complicated parsing required.

That is very neat Bill!  I had forgotten that Velocity converts the string
already into a List.  Velocity rocks.

> Attributes in XML/HTML tags are the same idea even though the Map isn't 
> accessable.

Cool.  What I don't think I said properly, but what I meant is I haven't
seen a language that supports the ability to create a Map-type-object and
initialise it with values at declaration like you can with, as an example,
an array in Java (.e.g String[] string = new String[]{"blah", "blah",
"blah"};)  The syntax for doing something similar for a Map seems to be
harder to read, and I wonder if that's why it's never been done.

Anyway, that Map idea you had Bill is cool, I think I'll have a use for
that.  thanks.

Paul

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