Am Montag, 16. April 2007 14:56 schrieb Grégory Joseph:
> Hi gang,
>
> Currently working on a FreemarkerParagraphRenderer, I'd like to
> gather opinions about the syntax to be used. There are plenty of
> options and approaches. I currently see the following (if
> implementable at all) :
>
> ${foo} : would return a node (Content)
> ${foo['bar']} : would return the bar property (NodeData) of the foo node
> ${foo.baz} : would return foo's child node called bazI 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. > <#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 > > I have a few doubts: > * 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. > * 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. > * 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? > 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) ---------------------------------------------------------------- for list details see http://www.magnolia.info/en/developer.html ----------------------------------------------------------------
