From d9aa70301432214ffe3c665a1d961fab705179c4 Mon Sep 17 00:00:00 2001 From: Chris Buckley Date: Mon, 9 Jun 2014 12:28:54 +0100 Subject: [PATCH] Only access properties of objects on Context.lookup --- mustache.js | 2 +- test/_files/bug_length_property.js | 3 +++ test/_files/bug_length_property.mustache | 1 + test/_files/bug_length_property.txt | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/_files/bug_length_property.js create mode 100644 test/_files/bug_length_property.mustache create mode 100644 test/_files/bug_length_property.txt diff --git a/mustache.js b/mustache.js index 46cd5c1..dbc9823 100644 --- a/mustache.js +++ b/mustache.js @@ -368,7 +368,7 @@ while (value != null && index < names.length) value = value[names[index++]]; - } else { + } else if (typeof context.view == 'object') { value = context.view[name]; } diff --git a/test/_files/bug_length_property.js b/test/_files/bug_length_property.js new file mode 100644 index 0000000..74c483b --- /dev/null +++ b/test/_files/bug_length_property.js @@ -0,0 +1,3 @@ +({ + length: 'hello' +}) diff --git a/test/_files/bug_length_property.mustache b/test/_files/bug_length_property.mustache new file mode 100644 index 0000000..b000887 --- /dev/null +++ b/test/_files/bug_length_property.mustache @@ -0,0 +1 @@ +{{#length}}The length variable is: {{length}}{{/length}} diff --git a/test/_files/bug_length_property.txt b/test/_files/bug_length_property.txt new file mode 100644 index 0000000..f5355d3 --- /dev/null +++ b/test/_files/bug_length_property.txt @@ -0,0 +1 @@ +The length variable is: hello