| [#ftl] |
| <html> |
| <head> |
| <title>FreeMarker: Variable Test</title> |
| </head> |
| <body> |
| [#assign list = ["one", "two", "three", "four", "five"]] |
| [#assign hash = {"output" : "My message.", "key" : list}] |
| [#assign hash2 = {"value" : hash}] |
| [#assign items = {"mykey" : "key", "_test", "out"}] |
| |
| <p>A simple test follows:</p> |
| |
| <p>${message}</p> |
| |
| <p>Now get into variable nesting:</p> |
| |
| <p>${hash.output}</p> |
| <p>${hash["output"]}</p> |
| <p>${hash. output}</p> |
| <p>${hash .output}</p> |
| <p>${hash |
| .output}</p> |
| <p>${hash |
| . output}</p> |
| <p>${hash ["output"]}</p> |
| <p>${hash |
| [ "output" ]}</p> |
| |
| <p>More deep nesting...</p> |
| |
| <p>${hash2.value.output}</p> |
| <p>${hash2.value.key[0]}</p> |
| <p>${hash2["value"]["key"][0]}</p> |
| |
| |
| <p>Nesting inside nesting...</p> |
| |
| <p>${hash2.value[ items.mykey ][ 1 ]}</p> |
| <p>${hash2.value[ items[ "mykey" ]][ 1 ]}</p> |
| <p>${hash2.value[ items[ "my" + items.mykey ]][ 1 ]}</p> |
| <p>${hash2.value[ items[ "my" + items["mykey"] ]][ 1 ]}</p> |
| |
| <p>Test underscores...</p> |
| |
| <p>${items[ "_test" ]}</p> |
| <p>${items._test}</p> |
| |
| ${"God save the queen."?word_list[1]?upper_case} |
| |
| </body> |
| </html> |