File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ <!-- exciting part -->
1
2
< h1 > {{name}}</ h1 >
2
3
< p > Authors: < ul > {{#authors}}< li > {{.}}</ li > {{/authors}}</ ul > </ p >
3
4
< p > Price: {{price.currency.symbol}}{{price.value}} {{#price.currency}}{{name}} < b > {{availability.text}}</ b > {{/price.currency}}</ p >
4
- < p > VAT: {{price.currency.symbol}}{{price.vat}}</ p >
5
+ < p > VAT: {{price.currency.symbol}}{{price.vat}}</ p >
6
+ <!-- boring part -->
7
+ < h2 > Test truthy false values:</ h2 >
8
+ < p > Zero: {{truthy.zero}}</ p >
9
+ < p > False: {{truthy.notTrue}}</ p >
Original file line number Diff line number Diff line change @@ -14,5 +14,10 @@ var dot_notation = {
14
14
availability :{
15
15
status : true ,
16
16
text : "In Stock"
17
+ } ,
18
+ // And now, some truthy false values
19
+ truthy : {
20
+ zero : 0 ,
21
+ notTrue : false
17
22
}
18
23
} ;
Original file line number Diff line number Diff line change
1
+ <!-- exciting part -->
1
2
<h1>A Book</h1>
2
3
<p>Authors: <ul><li>John Power</li><li>Jamie Walsh</li></ul></p>
3
4
<p>Price: €200 Euro <b>In Stock</b></p>
4
5
<p>VAT: €40</p>
6
+ <!-- boring part -->
7
+ <h2>Test truthy false values:</h2>
8
+ <p>Zero: 0</p>
9
+ <p>False: false</p>
Original file line number Diff line number Diff line change @@ -272,7 +272,10 @@ var Mustache = function() {
272
272
273
273
// check for dot notation eg. foo.bar
274
274
if ( name . match ( / ( [ a - z _ ] + ) \. / ig) ) {
275
- value = is_kinda_truthy ( this . walk_context ( name , context ) ) ;
275
+ var childValue = this . walk_context ( name , context ) ;
276
+ if ( is_kinda_truthy ( childValue ) ) {
277
+ value = childValue ;
278
+ }
276
279
}
277
280
else {
278
281
if ( is_kinda_truthy ( context [ name ] ) ) {
You can’t perform that action at this time.
0 commit comments