diff --git a/mustache.js b/mustache.js index 90a66d3..641cebd 100644 --- a/mustache.js +++ b/mustache.js @@ -149,7 +149,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {}; localStack.push(context); } - if (context && target in context) { + if (context && typeof context === "object" && target in context) { value = context[target]; break; } diff --git a/spec/_files/string_as_context.js b/spec/_files/string_as_context.js new file mode 100644 index 0000000..784368b --- /dev/null +++ b/spec/_files/string_as_context.js @@ -0,0 +1,4 @@ +var string_as_context = { + a_string: 'aa', + a_list: ['a','b','c'] +}; diff --git a/spec/_files/string_as_context.mustache b/spec/_files/string_as_context.mustache new file mode 100644 index 0000000..c6aa11a --- /dev/null +++ b/spec/_files/string_as_context.mustache @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/spec/_files/string_as_context.txt b/spec/_files/string_as_context.txt new file mode 100644 index 0000000..35e6306 --- /dev/null +++ b/spec/_files/string_as_context.txt @@ -0,0 +1,5 @@ + \ No newline at end of file