FreeMarker: Test of Multiple Model implementations

Let's begin with a simple model:

${message}

Cool, now get into the first model. This implements a scalar, list, and hash as a single class. Let's try some tests...

${data}

Now as a list...

<#foreach item in data>${item}

Index into a list...

${data[ 1 ]}

List size is: ${data.size}

List size is: ${data["size"]}

Now, again, as a hash. First using dot notation, then using [] notation:

${data.selftest}

${data["selftest"]}

Now for the tricky stuff... use a model to index into another model...

${test}

${data[ test ]}

${self}

${data[ self + "test" ]}

Same thing, this time a List index...

${zero}

${data[ zero ]}

${data[ zero + 1 ]}

Now, do the same recursively...

${data}

${data.model2}

${data.model2( "test" )}

${data.model2( data, data.selftest, message )}

Does this really not work?

${data[ 10 ]}

${data[ 10 ].selftest}

${data[ 10 ].message}

(Again, with Hashes)

${data.nesting1.nested}

${data.nesting1.nested.selftest}

${data["nesting1"].nested}

${data["nesting1"].nested["selftest"]}

${data["nesting1"]["nested"]["selftest"]}

As I suspected! (Manual on Expressions needs updating.)

Second test on list size

${data.one.size}

${data.one["size"]}