0

I have the following velocity code.

#foreach($content in $list)
   #set($map = {$content.categoryName:[]})

   #foreach($child in $children)
      // I want to add values to $map.$content.categoryName
   #end
#end

I would like to add values to $map.$content.categoryName. I tried

$map.$content.categoryName.add(values here) 

but it didn't work. I also tried

$map[$content.categoryName].add(values here)

But it still didn't work. Could someone please help me with this problem.

wattostudios
  • 8,666
  • 13
  • 43
  • 57
Moon
  • 22,195
  • 68
  • 188
  • 269

1 Answers1

2

It's java, not javascript:

$map.get($content.categoryName).add($child.value)

Nathan Bubna
  • 6,823
  • 2
  • 35
  • 36
  • No :) But i'm just very used to people confusing the two in both syntax and server vs client side render-time. So i make totally uncalled-for assumptions like that sometimes. My apologies! – Nathan Bubna Apr 29 '11 at 14:38
  • // no..no need to apologies. I just looked up my question and i was like.. "oh..did I post a wrong question..?" – Moon May 01 '11 at 02:18
  • Actually, you are adding values to a list, not a map. The map just happens to be in a map. – Will Glass Jun 25 '11 at 01:13