Re: [Freemarker-devel] Ideal tag syntax; what's your take on it?
Daniel Henrique Alves Lima <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user,gmane.comp.web.freemarker.devel |
|---|---|
| Message-ID | <[email protected]> |
Denis Bredelet wrote:
>
> The real advantage of Velocity syntax is that it uses line-ending as a delimiter. That sometimes complicates white space handling but it is visually nicer.
>
>
Visually nicer? For some cases, I disagree.
http://velocity.apache.org/engine/releases/velocity-1.7/vtl-reference-guide.html
<li>#if( $foo == $bar)it's true!#{else}it's not!#end</li>
I have some horrible examples of Velocity (I just need to find them :-))
where the sentences were made unreadable just to avoid extra space or
line break.
Some examples of redundant notation in Velocity:
* Variable reference: #set( $monkey = $bill )
* String literal: #set( $monkey.Friend = 'monica' )
* Property reference: #set( $monkey.Blame = $whitehouse.Leak )
* Method reference: #set( $monkey.Plan = $spindoctor.weave($web) )
* Number literal: #set( $monkey.Number = 123 )
* Range operator: #set( $monkey.Numbers = [1..3] )
* Object list: #set( $monkey.Say = ["Not", $my, "fault"] )
* Object map: #set( $monkey.Map = {"banana" : "good", "roast beef" :
"bad"})
I would prefer (I'm not considering if it is doable):
* Variable reference: #set monkey = bill
* String literal: #set monkey.friend = 'monica'
* Property reference: #set monkey.blame = whitehouse.leak
* Method reference: #set monkey.plan = spindoctor.weave(web)
* Number literal: #set monkey.number = 123
* Range operator: #set monkey.numbers = [1..3]
* Object list: #set monkey.say = ["Not", my, "fault"]
* Object map: #set monkey.map = {banana : "good", "roast beef" : "bad"}
The last one is tricky. It's the Groovy approach for a Map literal,
but I agree it probably isn't a good idea in a Template language.
http://groovy.codehaus.org/Collections
'(...) Map keys are strings by default: [a:1] is equivalent to ["a":1].
But if you really want a variable to become the key, you have to wrap it
between parentheses: [(a):1]. (...)'
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev