Re: [FreeMarker-user] Benefits of [#ftl]

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: [FreeMarker-user] Benefits of [#ftl]

Daniel Dekany
I move this thread over the devel list. Please respond to there.

Thursday, May 10, 2007, 11:43:02 PM, Johannes Klose wrote:

> Daniel Dekany wrote:
>> Thursday, May 10, 2007, 12:37:44 AM, Johannes Klose wrote:
>>>> Maybe we really should make the square syntax standard in 2.4 (which
>>>> maybe should be 3.0 BTW). It is trivial to include a template
>>>> canonicalizer that converts existing templates to the square brackets.
>>> Why don't leave the decision to the user and make it mandatory to choose
>>> a syntax flavor, like
>>>     Configuration conf = new Configuration();
>>>     conf.setSyntaxStyle(SQUARE_BRACKET);
>>> Or, even better, leave it to the user to choose which characters to use
>>> vor ftl tags, like
>>>     conf.setTagStart('[');
>>>     conf.setTagEnd(']');
>> Yes, that would be a solution, however it can create quite a confusion
>> as well. At least, different extensions should be used fro different
>> syntax, so there will be at least a theoretical hope for syntax
>> highlight in editors. Ideally, the FreeMarker syntax in editors should
>> be easily configurable, like in the configuration of FreeMarker. Like,
>> the Eclipse plugin could have settings, where you can ma the syntax
>> properties to file extensions.
> The freemarker-ide plugin needs to be configured per template anyway (to
>  provide a mapping from template vars to pojos for the sake of
> auto-completion) so i don't think it would be a problem to add a syntax
> style property.

Just note again that the syntax should be chosen pretty much
automatically. Like based on file extension. It think the ftl
extension should be reserved for the "standard" syntax.

>>> Well ... german keyboards are ugly for programmers in general as
>>> this also applies to {} ... ;)
>> Hungarian keyboard is ugly for that as well, but here almost everybody
>> switches to English keyboard layout for source code editing anyway.
>> (For those who don't know, like maybe US and GB people, in Windows you
>> can install multiple layouts, and switch between them with hot-key.)
>> Germans don't used to do this?
> Some people do. I also know people who use a us keyboard in general. You
> always know that someone uses a us keyboard when he writes 'ae' instead
> of 'ä', 'oe' instead of 'ö' and so on because the us keyboard doesn't
> have german umlauts ;)
>>> Anyway, one of many reasons for me to use freemarker was the
>>> nice <> syntax so i'd really like to see it in future versions
>>> too.
>> Here we come... is <> nice? Then comes another user saying that the
>> reason he does NOT use FreeMarker is the ugly <> syntax... :)
> That's why i'd prefer to make the syntax style a configuration option.
> Everyone has reasons for prefering his style above others and it's
> impossible to satisfy everybody. Choice ftw :)

While from purely technical point of view that's the best solution,
because of "social" factors it involves a risk, that although could be
addressed by communicating things well, I'm not 100% sure that will be
enough. Concretely, for me it has become clear that people are prone
to dislike a template language syntax from irrational psychological
reasons, and this being kind of emotional thing, they are not prone to
change their opinions in that question. This can give a rise to the
usage of custom syntaxes. As far as it is only the problem of the
inventor of the custom syntax, it is not a big problem, its a "suit
yourself" thing. But today one-man projects are more and more rare
(especially considering the whole life-cycle of the application), and
it will have an obvious negative effect if people face unknown custom
variations here and there, instead of the more widely known and
documented (consider Manual examples and so on) and supported standard
syntax. But of course there are cases when there is good reason to
introduce a custom syntax. Even in those cases it should be made clear
for the users that they should not use the ftl extension.

There is also a technical side of the thing. FreeMarker was not
designed to support multiple syntaxes simultaneously. I mean, you may
want to use templates of a custom syntax together with "libraries"
(collections of macros) that use standard syntax. So I think that
FreeMarker should always parse templates that use the ftl extension
with the standard syntax, and the custom syntax would apply only to
the other templates. This would also solve the lastly mentioned social
problem. Sure, given that many users prefer to use other extensions or
not using extensions (consider templates stores not in file system or
in jar but in DB) this solution is awkward, but since I don't think
that the over architecture of FreeMarker (which is flawed on numerous
ways) will be redesigned at this point of history, we might as well go
away with this solution.

But... it's not like any of the FreeMarker developers has stared
working on truly configurable syntax.

Best regards,
 Daniel Dekany

This email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
FreeMarker-devel mailing list
[hidden email]