diff --git a/mustache.js b/mustache.js index 413b6f2..56d6d6f 100644 --- a/mustache.js +++ b/mustache.js @@ -377,11 +377,11 @@ if (cache.hasOwnProperty(name)) { value = cache[name]; } else { - var context = this, names, index, lookupHit = false; + var context = this, intermediateValue, names, index, lookupHit = false; while (context) { if (name.indexOf('.') > 0) { - value = context.view; + intermediateValue = context.view; names = name.split('.'); index = 0; @@ -396,19 +396,21 @@ * This is specially necessary for when the value has been set to * `undefined` and we want to avoid looking up parent contexts. **/ - while (value != null && index < names.length) { + while (intermediateValue != null && index < names.length) { if (index === names.length - 1) - lookupHit = hasProperty(value, names[index]); + lookupHit = hasProperty(intermediateValue, names[index]); - value = value[names[index++]]; + intermediateValue = intermediateValue[names[index++]]; } } else { - value = context.view[name]; + intermediateValue = context.view[name]; lookupHit = hasProperty(context.view, name); } - if (lookupHit) + if (lookupHit) { + value = intermediateValue; break; + } context = context.parent; } diff --git a/test/_files/dot_notation.mustache b/test/_files/dot_notation.mustache index f89d70b..2640514 100644 --- a/test/_files/dot_notation.mustache +++ b/test/_files/dot_notation.mustache @@ -7,3 +7,4 @@
Zero: {{truthy.zero}}
False: {{truthy.notTrue}}
+length of string should not be rendered: {{price.currency.name.length}}
diff --git a/test/_files/dot_notation.txt b/test/_files/dot_notation.txt index 08afa05..eeb346d 100644 --- a/test/_files/dot_notation.txt +++ b/test/_files/dot_notation.txt @@ -7,3 +7,4 @@Zero: 0
False: false
+length of string should not be rendered: