From 4adfb48205e00068051657695d8d4184c9a94da1 Mon Sep 17 00:00:00 2001 From: utvara Date: Sat, 11 Feb 2012 23:18:44 +0100 Subject: [PATCH 1/2] Fixed a bug when context is a string --- mustache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From 13007fd9d609bf25adbb6f7af5a7b60c9f9c4f8c Mon Sep 17 00:00:00 2001 From: utvara Date: Fri, 24 Feb 2012 00:52:16 +0100 Subject: [PATCH 2/2] added test case for string as a context --- spec/_files/string_as_context.js | 4 ++++ spec/_files/string_as_context.mustache | 5 +++++ spec/_files/string_as_context.txt | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 spec/_files/string_as_context.js create mode 100644 spec/_files/string_as_context.mustache create mode 100644 spec/_files/string_as_context.txt 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