lmi
[Top][All Lists]
Advanced

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

[lmi] How logic-less is mustache?


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

I'm guessing that mustache templates are _absolutely_ "logic-less".
It's just a little surprising to see, e.g.,
  {{^StateIsNewYork}}
when we already know the state and only want to compare it to "NY"; or
      Separate Account: 
{{GenAcctAllocationComplementPercent}}<br>☜
  &nbsp;&nbsp;&nbsp;&nbsp;Guaranteed Principal Account (GPA): 
{{GenAcctAllocationPercent}}<br>☜
where one variable is just 100% minus the other, especially in light of
the way I initially read mustache's "Hello, world!" equivalent:

| A typical Mustache template:
|
| Hello {{name}}
| You have just won {{value}} dollars!
| {{#in_ca}}
| Well, {{taxed_value}} dollars, after taxes.
| {{/in_ca}}
| Given the following hash:
|
| {
|   "name": "Chris",
|   "value": 10000,
|   "taxed_value": 10000 - (10000 * 0.4),
|   "in_ca": true
| }

I mean, we can do arithmetic:
|   "taxed_value": 10000 - (10000 * 0.4),
but that's input provided to mustache, rather than mustache code, right?

Mustache has 'lambdas', but they aren't a back door through which
we can introduce, e.g., a "complement" function like:
  (lambda (x) (- 1 x))

I'm sure this is all by design. It's just startling that we need to
define a "StateIsNewYork" variable.



reply via email to

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