Re: [FreeMarker-user] Ideal tag syntax; what's your take on it?

Denis Bredelet <[email protected]>
Newsgroups gmane.comp.web.freemarker.devel,gmane.comp.web.freemarker.user
Message-ID <[email protected]>
> Friday, June 10, 2011, 8:36:15 AM, Denis Bredelet wrote:
> 
> [snip]
>> 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.
> [snip]
> 
> AFAIK, you don't have to break the line after Velocity directives.
> It's enough if you close the parentheses, or if there are none, if
> it's followed by an unexpected character.
> 
> Beside, those problems of the Velocity syntax can be solved easily
> (like, require () even if the directive has no parameters). So then I
> read this as you are in favor of Velocity look-and-feel in general.

I am in favor of the Velocity *directive* look and feel in HTML or XML templates. 

> 
>>> How FTL is still similar to SGML:
>>> 
>>> - You have to add a "/" to each empty-directive tag ([@foo /]), but
>>> you don't have to add anything if nested content follows
>>> ([@foo]...). Isn't that anti-intuitive and often inconvenient?
>>> Nothing but SGML has this strange upside-down logic (I think).
>>> 
>>> Also, to complicate things... there are those who are more equal
>>> than others. For a built-in directive you can write something like
>>> [#assign x = 1] instead of [#assign x = 1 /], since FreeMarker knows
>>> if they can have nested content or not.
>> 
>> In my opinion the issue is not with the closing of an empty
>> directive, but with the end of directive syntax. The slash is short
>> (1 character) but cryptic, it is not clear it means "end". My
>> suggestion is to introduce an alternative syntax. Maybe:
>> 
>> [@foo @end]
>> [@foo]
>> [@end]
>> 
>> Equivalent to [@foo][/@]
>> 
>> (May need to use #end instead of @end because the latter is valid
>> directive name AFAIK so it wouldn't be backward-compatible)
> 
> We don't really care about BC in this discussion. The problem is
> rather that [@foo @end] is awfully verbose, also [#foo #end]. How
> about this:
> 
>  [#foo :]
>    ...
>  [#end]
> 
> and if you don't have nested content
> 
>  [#foo]
> 
> So the colon makes it obvious that we have started the nested content
> and so there's a matching @end somewhere. You can also extend the
> concept with:
> 
>  [#foo :]
>    ...
>  [#end-foo]
> 
> so that optionally, you can tell what directive are you closing.
> 
> But my problem is that while "end" is self-explanatory, it's too
> verbose. That verboseness is OK for a Velocity-ish syntax, because
> that don't have the [...]-s to help separating tags for the static
> text. But here... it's "[@end" is too much IMO.

I really don't mind the verboseness here. Keep [/@] as a shortcut. 

> Anyway, what I was
> originally thinking about is:
> 
>  [#foo {]
>    ...
>  [}]
> 
>  or [} #foo], optionally.
> 
> and
> 
>  [#foo]
> 
> Quite obvious. I was happy with the idea, until I tried it in real
> templates, and there I found it looks kind of noisy, because the {}-s
> and [] looks to similar. That's maybe nit-picking, but... I have found
> that despite it's *weird* and has steeper "learning curve", this looks
> better after you get used to it:
> 
>  [#foo :]
>    ...
>  [#.]

Ok but if we use colon for named arguments it will clash. How about:

[#foo]
...
[#.]

[#foo.]

> 
>  or [#. foo], optionally.

-- Denis. 

------------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.