tags:

views:

172

answers:

1

Hello,

I have an array set inside a velocity template that contains some paths.
The idea is to put a few "default" .js/.css files that 90% of the pages will use in this array.
However, the other pages will still have to be able to add/delete values from this array, in case there are no linked files at all, or I need to add some.

Given this code:

#set ( $head.scripts = [ "https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js" ] )

#foreach ($URI in $head.scripts)
<script type="text/javascript" src="$URI"></script>
#end

is there any way to add/delete values from these defaults?
I have seen this list tool, but it looks like it's not enough for what I need.

A: 

If this array is created in Velocity then it is backed by ArrayList class, so it supports all corresponding methods.

$head.scripts.add("new element")
$head.scripts.remove(0)
serg
This works nicely, thank you!
Razor
Can you answer this question : http://stackoverflow.com/questions/2799618/list-in-velocity-macro-cannot-find-contains-method?
fastcodejava