Comments (2)
Any helper parameter that is not surrounded by quotes will be considered a reference. Consider this example:
JSON:
{
"false":"mypropertyWithNameFalse"
}
and template
{@eq key=false type="string" value="mypropertyWithNameFalse"}
same
{:else}
not same
{/eq}
Dust will grab value of false
key from context and as a result will render same
.
In order for your example to work you'll need to pass in false
in as a string and use type="boolean"
parameter on eq
helper like so:
{@eq key=val value="false" type="boolean"}
In this case values of key
and value
parameters will be coerced to boolean type and you'll get the result you are looking for.
Alternatively you could do type="string"
to convert and compare values as strings. But there seems to be an issue with coerce
not coercing falsy values. I think that's a bug and it needs to be fixed.
from dustjs-helpers.
Unrelated to the problem, but you can write this like:
{#.}
{^val}
FALSE
{:else}
TRUE
{/val}
{/.}
from dustjs-helpers.
Related Issues (20)
- Testing sub boolean value HOT 2
- Drop Node 0.8 support
- breaking semver and my sites HOT 2
- Helpers 1.6.0 and dustjs-linkedin 2.6.0 can break some apps HOT 13
- @default and @none helpers not working properly on 1.6.0 version HOT 12
- Don't require a key for {@select} HOT 5
- {@select}s with multiple keys break when used with {@any} / {@none}
- Feature regression in 1.7.0, logic helpers ignored in select bodies HOT 9
- Cannot use 'else' as a property in IE8 HOT 1
- Sync test framework changes / saucelabs
- @select fails to render multiple @eq statements inside a @none block HOT 7
- Make use of context options to store @select state
- Add case-insensitive {@eq} comparator HOT 12
- Issue in running in production mode
- @eq helper doesn't work when accessing an object at a deeper level HOT 7
- Fix Travis tests by not supporting node 0.10 and node 0.12
- Support dustjs v3.0.0 HOT 4
- deprecate and remove if helper HOT 4
- Peer dependencies issue with dustjs-linkedin HOT 16
- Is there a reason why there is no loop helper? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dustjs-helpers.