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