A simple test follows:
${message}
Now perform a hash assignment:
<#assign mymessage = "hello", foo="bar", one="1"> <#assign test = { "test1": "test23", "test45" : message, mymessage : "hello all", foo: one}> ${test.test1} ${test.test45} ${test.hello} ${test.bar}Now update the assignment and repeat:
<#assign mymessage = "world"> ${test.test1} ${test.test45} ${test.hello} ${test.bar}Now reassign the list and repeat:
<#assign hash= {"temp" : "Temporary"}> <#assign test = { "test1" : "test23", "test45" : message, mymessage : "hello all", foo : one, "hash" : hash[ "temp" ], "true" : hash.temp, "newhash" : hash}> ${test.test1} ${test.test45} ${test.hello?if_exists} ${test.bar} ${test.hash} ${test.true} ${test.newhash.temp}Pathological case: zero item hash:
<#assign test = {}> ${test.test1?if_exists}Hash of number literals:
<#assign test = {"1" : 2}> ${test["1"]}Hash concatenation:
<#assign cc = { "a" : 1, "b" : 2 } + { "b" : 3, "c" : 4 }> <#list cc?keys?sort as key> ${key} => ${cc[key]} #list>Empty hash concatenation:
${({} + { "a" : "foo" }).a}, ${({ "a" : "bar" } + {}).a}