Elias Zamaria
Elias Zamaria

Reputation: 101103

change subvariable in FreeMarker

Is there a way to change a subvariable within a hash or a container in a FreeMarker template? For example, suppose I had:

{"name":"Bob", "city":"Detroit", "state":"OH"}

and I want to change the state to "MI". How would I go about doing that? I know about the assign tag, but the documentation says "Note that only top-level variables can be created/replaced". I am unsure as to whether this means subvariables can't be replaced with the assign tag, or subvariables can't be replaced by any means.

Upvotes: 4

Views: 2833

Answers (1)

Elias Zamaria
Elias Zamaria

Reputation: 101103

I figured out a simple way to do it:

<#assign hash = hash + {"state":"MI"}>

Upvotes: 12

Related Questions