lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] How logic-less is mustache?


From: Greg Chicares
Subject: Re: [lmi] How logic-less is mustache?
Date: Wed, 25 Oct 2017 21:51:42 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 2017-10-25 20:47, Vadim Zeitlin wrote:
> On Wed, 25 Oct 2017 19:51:56 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> I'm guessing that mustache templates are absolutely "logic-less".
> 
>  Yes. This is the difference between Mustache and Handlebars, which uses
> the same syntax, but extends it with some minimal logic. I admit that I
> regretted the absence of logic in Mustache quite a few times while writing
> this code, especially because the separation of presentation from data, which
> is the main advantage of the Mustache approach, is not that strong anyhow in
> our case due to all the tables which need to be defined in C++ code.
> 
> GC> It's just a little surprising to see, e.g.,
> GC>   {{^StateIsNewYork}}
> GC> when we already know the state and only want to compare it to "NY"; or
> GC>   &nbsp;&nbsp;&nbsp;&nbsp;Separate Account: 
> {{GenAcctAllocationComplementPercent}}<br>☜
> GC>   &nbsp;&nbsp;&nbsp;&nbsp;Guaranteed Principal Account (GPA): 
> {{GenAcctAllocationPercent}}<br>☜

[I've been experimenting with a dark gray '☜' EOL highlight in vim.
I must have copied from the screen there, instead of using '"+y'.]

> GC> where one variable is just 100% minus the other,
> 
>  I hesitated for a long time, but I finally felt that the inconvenience of
> having to define all these variables wasn't worth the extra effort of
> writing and the extra complexity of maintaining an expression parser. I
> could have been wrong and I could write such a parser now, of course, if
> you think it'd be worth it.

Certainly not right now.

In the old days, typewriter manufacturers marketed their product to
high-school students by pointing out that errors stand out better,
and are thus easier to fix, in typed vs. handwritten papers.
Expressing lmi's reporting logic clearly has made ancient design
errors poignant. There's much we should undo in that design before
we redo the implementation in what is at best only an incrementally
better template language.

> GC> Mustache has 'lambdas', but they aren't a back door through which
> GC> we can introduce, e.g., a "complement" function like:
> GC>   (lambda (x) (- 1 x))
> 
>  Yes, what we'd really like to have would be Handlebars "helpers" and
> conditionals (see http://handlebarsjs.com/block_helpers.html if you're
> curious).

Let's not use handlebars--this "simple" example, e.g.:
  {{#each user.book as |book bookId|}}
is not what I'd call pellucid.

>From time to time, I go back and read the mustache man page.
It takes about five minutes. At the end, I marvel that there's
nothing else to it. It's the opposite of git in this respect:
you can dig deeper and deeper, and there's still nothing else.

mustache : interlingua :: handlebars : volapük



reply via email to

[Prev in Thread] Current Thread [Next in Thread]