Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed a bug when context is a string #164

Merged
merged 2 commits into from

2 participants

@utvara
var view = {
        type: 'aa',
        items: ['a','b','c']
}

template:

<ul>
{{#items}}
    <li><a href="#{{type}}/{{.}}">{{.}}</a></li>
{{/items}}
</ul>
@janl
Owner

Can you add a test case for this?

@utvara

Done.

Sorry I didn't do it in the first place :(

@janl
Owner

thanks! no worries :)

@janl janl merged commit 4e94d04 into janl:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 11, 2012
  1. @utvara
Commits on Feb 23, 2012
  1. @utvara
This page is out of date. Refresh to see the latest.
View
2  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;
}
View
4 spec/_files/string_as_context.js
@@ -0,0 +1,4 @@
+var string_as_context = {
+ a_string: 'aa',
+ a_list: ['a','b','c']
+};
View
5 spec/_files/string_as_context.mustache
@@ -0,0 +1,5 @@
+<ul>
+{{#a_list}}
+ <li><a href="#{{a_string}}/{{.}}">{{.}}</a></li>
+{{/a_list}}
+</ul>
View
5 spec/_files/string_as_context.txt
@@ -0,0 +1,5 @@
+<ul>
+ <li><a href="#aa/a">a</a></li>
+ <li><a href="#aa/b">b</a></li>
+ <li><a href="#aa/c">c</a></li>
+</ul>
Something went wrong with that request. Please try again.