I think freemarker doesn't in general make a distinction between foo.baz and foo['baz']. Either should return the same value. ie the property or child named 'baz'. In our case either a wrapped NodeData or a wrapped Content.

Then how to deal with nodes which have a child called "bar" AND a property with the same name? One of them will have priority, but the other one should still be available to the template, how to deal with this?


<#list foo as n> ... : would loop over the properties of foo

probably best to stick with the freemarker built in for extended hashes:
<#list foo?keys as key>

http://freemarker.sourceforge.net/docs/ref_builtins_hash.html

<#list foo.children as n> ... : would loop over the child nodes of foo

probably best here to stick with the freemarker built in for nodes:
<#list foo?children as n>

http://freemarker.sourceforge.net/docs/ref_builtins_node.html

Totally agreed, I had overlooked the TemplateNodeModel interface, thanks for pointing it out.

* since properties could be used more often than subnodes in
templates, it might be interesting to revert the [] notation: foo.bar
would mean "bar property of foo" while foo['bar'] would mean "bar
child of foo", eventhough that doesn't seem very intuitive from my
programmer's point of view.

foo['bar'] should be the same as foo.bar.

Same question as above.

* the iterators i propose here are inconsistent with the properties/
child notation, and would prevent access to a sub node called
"children".

not really since the syntax is different. foo?children is not the same as
foo.children.

Agreed, now that you've pointed this out above.

*  how to expose other Content properties, such as handle and uuid?
Chris suggests using [EMAIL PROTECTED] or [EMAIL PROTECTED] OTOH, I'm not
convinced these should be used very often in templates,

is 'should' here prescriptive or descriptive?

Err, as to not get lost in english grammar (which as it shows I do not master), I meant: I'm under the impression that most templates will not need - or not very often - to output the handle or uuid of the nodes they're rendering.

so maybe
having a few custom directives would be good enough (<@uuid>${foo}</
@uuid>)

Here's yet another idea regarding how to handle 'handle': have $ {foo} by
itself be the handle?  This would correspond to the content wrapper
implmenting TemplateScalarModel (getAsString)

Sounds fair enough for handle, but doesn't help much in exposing other properties (uuid, depth, ...)

g



----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/developer.html
----------------------------------------------------------------

Reply via email to