From 18a0e89640c514b1b5bdab03880db7711f455179 Mon Sep 17 00:00:00 2001
From: brandonpayton Authors: {{name}}
{{#authors}}
Price: {{price.currency.symbol}}{{price.value}} {{#price.currency}}{{name}} {{availability.text}}{{/price.currency}}
-VAT: {{price.currency.symbol}}{{price.vat}}
\ No newline at end of file +VAT: {{price.currency.symbol}}{{price.vat}}
+ +Zero: {{truthy.zero}}
+False: {{truthy.notTrue}}
diff --git a/examples/dot_notation.js b/examples/dot_notation.js index f41fafb..a28f8db 100644 --- a/examples/dot_notation.js +++ b/examples/dot_notation.js @@ -14,5 +14,10 @@ var dot_notation = { availability:{ status: true, text: "In Stock" + }, + // And now, some truthy false values + truthy: { + zero: 0, + notTrue: false } -}; \ No newline at end of file +}; diff --git a/examples/dot_notation.txt b/examples/dot_notation.txt index 770e4ce..d0e4707 100644 --- a/examples/dot_notation.txt +++ b/examples/dot_notation.txt @@ -1,4 +1,9 @@ +Authors:
Price: €200 Euro In Stock
VAT: €40
+ +Zero: 0
+False: false
diff --git a/mustache.js b/mustache.js index 21d5726..4310d70 100644 --- a/mustache.js +++ b/mustache.js @@ -272,7 +272,10 @@ var Mustache = function() { // check for dot notation eg. foo.bar if(name.match(/([a-z_]+)\./ig)){ - value = is_kinda_truthy(this.walk_context(name, context)); + var childValue = this.walk_context(name, context); + if(is_kinda_truthy(childValue)) { + value = childValue; + } } else{ if(is_kinda_truthy(context[name])) { @@ -416,4 +419,4 @@ var Mustache = function() { } } }); -}(); \ No newline at end of file +}(); From 55c434665617461cf369fa1bc47d5ce5b93a6b09 Mon Sep 17 00:00:00 2001 From: Brandon Payton