Tuesday, November 28, 2017, 4:45:01 PM, Jacques Le Roux wrote:

> Le 28/11/2017 à 16:43, Jacques Le Roux a écrit :
>>
>>
>> Le 28/11/2017 à 10:45, Daniel Dekany a écrit :
>>> This problem comes up again and again: the ${exp} syntax clashes with
>>> the syntax of the thing the user wants to generate. So I believe we
>>> need a Configuration option to address this. Something like
>>> cfg.setInterpolationSyntax(FOO_INTERPOLATION_SYNTAX), and also
>>> <#ftl interpolationSyntax="foo">.
>>>
>>> Like any syntax option, this is potentially confusing for users and
>>> problem for tools, but I don't think there's a way around this. Users
>>> have to deal with those clashing ${}-s somehow, and certainly an
>>> in-house hack will be worse and even more confusing. (Surely they can
>>> write ${'$'}{foo} or use #noparse, but if you need a lot of those,
>>> then it's obviously not an acceptable workaround.)
>>>
>>> So, what the syntax would be? Some of my ideas:
>>>
>>> - {{exp}} is probably the nicest. For the same reason it potentially
>>>    clashes with something yet again, though I guess it's unlikely
>>>    enough that neither ${exp} nor {{exp}} works for you.
>>>
>>> - @{exp}. It's similar to ${exp}, which I think is an advantage.
>>>    There's however a very small but still real chance that for someone
>>>    both ${} and @{} clashes with what they want to generate, because
>>>    using <someChar>{name} is somewhat popular.
>>>
>>> - #{exp}. That looks like the natural choice as we use # in tags as
>>>    well (also @, though). The reason I don't like it is that
>>>    we already have #{exp} in the standard syntax, but it's deprecated.
>>>    That's not a problem technically, as you can say that if you select
>>>    the #{} syntax, then it's not deprecated, and ${} will be treated
>>>    as static text. But now if someone sees #{exp}, they can't tell if
>>>    the template uses a deprecated syntax, or it uses the alternative
>>>    interpolation syntax. Also it's perhaps more likely that for someone
>>>    both ${} and #{} clashes (e.g. in the case you generate JSF JSP-s),
>>>    than that that both ${} and @{} clashes.
>>>
>>> - <=exp> and [=exp] depending on if you are using square- or
>>>    angle-bracket tag syntax. Look somewhat exotic... which also means
>>>    that hopefully it won't clash with anything.
>>>
>>> There's also the idea that we just let the user specify any separator,
>>> like `cfg.setInterpolationStart("@{"); cfg.setInterpolationEnd("}")`.
>>> But if all kind of random syntax is possible, it's harder for users to
>>> figure out what's going on (their syntax isn't mentioned in the
>>> Manual, and nobody on StackOverlfow recognizes it either), and it's
>>> more difficult to support that in tools as well. So I believe it's
>>> better for everyone if there's one, or maybe two standard
>>> alternatives. (Not to mention that I don't yet see how to implement
>>> such a runtime-configured syntax with the current JavaCC-based parser.
>>> Probably it would be a horrid hack if possible at all.)
>>>
>>> Opinions, ideas?
>>>
>>
>>
Oops wrong button =>> blank message :/
>
> I also prefer {{exp}} for the simple reason that it reminds me Jira
> and of course also for the reasons you explained

Though it has a different meaning there, so it doesn't necessarily
help. (Worse, for making template for Jira markup, you can't use
${exp} either... so this is actually one of those rather unlucky
cases.) What's a much bigger factor is Angular templates also use
{{exp}} for inserting values.

> Jacques
>
>

-- 
Thanks,
 Daniel Dekany

Reply via email to