On Tue, Jul 4, 2017 at 9:06 AM, Daniel Dekany <ddek...@apache.org> wrote:
> Tuesday, July 4, 2017, 7:29:23 AM, Woonsan Ko wrote:
>
>> On Fri, Jun 16, 2017 at 2:41 PM, Daniel Dekany <ddek...@apache.org> wrote:
> ---->>8---->8----
>>> Some very fundamental core directives still would have exceptional
>>> syntax, such as:
>>>
>>> - Assignments (#var/#set as planned for FM3). They look as if they
>>>   have named parameter syntax first, but in the future we might want to
>>>   allow things like `<#set x[i] = 1>` or `<#set ns.var = 1>`.
>>>
>>> - #macro and #function: As in pretty much all languages, the syntax for
>>>   defining callable things is not the same as the syntax for calling
>>>   things.
>>>
>>> - `<#list xs as x>`... though maybe it's not exceptional. `x` is just
>>>   a loop variable, and I haven't talked about the standardization of
>>>   that in this thread. But in FM2 it's like `<@myDirective blah;
>>>   loopVar1, loopVarN>`. But `<#list xs; x>` is IMO not very readable.
>>>   Maybe we should just allow `as` in place of `;` for custom
>>>   directives, optionally.
>>
>> How about <#list xs as="x">
>
> Loop variables (i.e., variables local to the nested content, set by
> the enclosing directive) is a commonly used thing in a FreeMarker
> (mostly because that #list is commonly used, but note that custom
> directives also can have loop variables). Thus, the syntax must make
> it clear that you create a loop variable there. If it's just `as="x"`,
> then you had to look up in the #list documentation what that does.
> More importantly, then tools won't know it.

I see. Yes, it seems better to keep it as-is: <#list xs as x>.

>
>> or <#list xs>? The latter could make 'it' available implicitly.
>
> `<#list xs>` in FM2 means that you have a nested `<#item as x>`.
>
> As of supporting `it` on other ways, I was thinking about that back
> then, but concluded that the loss in clarity doesn't worth it. The
> smaller problem is that unless you have Groovy background, you will
> have hard time realizing what's going on. The bigger problem is that
> especially when you have a longer section nested inside the #list call
> (and also when you have multiple #list-s nested into each other),
> seeing things like `${it.name}` is much less talking than seeing
> `${user.name}`. I'm certain that the majority of those users who know
> about `it` would overuse it, making FreeMarker templates less readable
> overall. If the user is enforced to give a name to the loop variable,
> then it's much less likely that they will call it `i` or `it`.

+1

>
>>> Along with these, I would like to remove `=` as a comparator operator
>>> (an alias to `==`). It was already a problem in FM2, as it leads to
>>> ambiguities because `=` is also used for named parameters, but if we
>>> allow the above things, then it's a much bigger problem.
>>
>> +1
>>
>>>
>>> I also would like to allow using `-` unescaped in directive and
>>> parameter names, like `<@my.foo-bar data-x=123 />` (This is a frequent
>>> FM2 request, but couldn't be done because of `=`.)
>>
>> +0 (since I don't know why it has been requested and I usually don't
>> use hyphen in names)
>
> It's because of the HTML 5 `data-...` attributes, and because many XML
> schemas use `-` in element and attribute names. We are affected by
> those because of declarative XML processing (where you name the
> handler macro after the element), and because of stuff like `<#macro m
> p1, p2, pN, extraHtmlAttrs...>`, which some want to call like `<@m 1,
> 2, 3 style='foo' data-bar="baaz" />`. (It's not something I have made
> up. It's a very frequent user request.)

I see. Thank you very much for the clear explanations! :-)

Cheers,

Woonsan

>
>
>> Regards,
>>
>> Woonsan
>>
>>>
>>> --
>>> Thanks,
>>>  Daniel Dekany
>>>
>>
>
> --
> Thanks,
>  Daniel Dekany
>

Reply via email to