From 53e9b2692b9ee03f6e902161421c6ff41e93a71b Mon Sep 17 00:00:00 2001 From: Aaron Gibralter Date: Wed, 12 May 2010 17:24:59 -0400 Subject: [PATCH] Partials within list sections did not seem to be functioning correctly. Since a list section pushes a sub-object of the "view" into the "current" context, a partial should recognize this altered context. The one-line change in mustache.js does exactly this. Closes #35. --- examples/array_of_partials_implicit_partial.2.html | 1 + examples/array_of_partials_implicit_partial.html | 5 +++++ examples/array_of_partials_implicit_partial.js | 3 +++ examples/array_of_partials_implicit_partial.txt | 5 +++++ examples/array_of_partials_partial.2.html | 1 + examples/array_of_partials_partial.html | 4 ++++ examples/array_of_partials_partial.js | 3 +++ examples/array_of_partials_partial.txt | 5 +++++ mustache.js | 2 +- 9 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 examples/array_of_partials_implicit_partial.2.html create mode 100644 examples/array_of_partials_implicit_partial.html create mode 100644 examples/array_of_partials_implicit_partial.js create mode 100644 examples/array_of_partials_implicit_partial.txt create mode 100644 examples/array_of_partials_partial.2.html create mode 100644 examples/array_of_partials_partial.html create mode 100644 examples/array_of_partials_partial.js create mode 100644 examples/array_of_partials_partial.txt diff --git a/examples/array_of_partials_implicit_partial.2.html b/examples/array_of_partials_implicit_partial.2.html new file mode 100644 index 0000000..12f7159 --- /dev/null +++ b/examples/array_of_partials_implicit_partial.2.html @@ -0,0 +1 @@ +{{.}} diff --git a/examples/array_of_partials_implicit_partial.html b/examples/array_of_partials_implicit_partial.html new file mode 100644 index 0000000..11537e9 --- /dev/null +++ b/examples/array_of_partials_implicit_partial.html @@ -0,0 +1,5 @@ +Here is some stuff! +{{%IMPLICIT-ITERATOR}} +{{#numbers}} +{{>partial}} +{{/numbers}} diff --git a/examples/array_of_partials_implicit_partial.js b/examples/array_of_partials_implicit_partial.js new file mode 100644 index 0000000..fcdf3b0 --- /dev/null +++ b/examples/array_of_partials_implicit_partial.js @@ -0,0 +1,3 @@ +var partial_context = { + numbers: ['1', '2', '3', '4'] +}; diff --git a/examples/array_of_partials_implicit_partial.txt b/examples/array_of_partials_implicit_partial.txt new file mode 100644 index 0000000..f622375 --- /dev/null +++ b/examples/array_of_partials_implicit_partial.txt @@ -0,0 +1,5 @@ +Here is some stuff! +1 +2 +3 +4 diff --git a/examples/array_of_partials_partial.2.html b/examples/array_of_partials_partial.2.html new file mode 100644 index 0000000..bdde77d --- /dev/null +++ b/examples/array_of_partials_partial.2.html @@ -0,0 +1 @@ +{{i}} diff --git a/examples/array_of_partials_partial.html b/examples/array_of_partials_partial.html new file mode 100644 index 0000000..1af6d68 --- /dev/null +++ b/examples/array_of_partials_partial.html @@ -0,0 +1,4 @@ +Here is some stuff! +{{#numbers}} +{{>partial}} +{{/numbers}} diff --git a/examples/array_of_partials_partial.js b/examples/array_of_partials_partial.js new file mode 100644 index 0000000..45611cf --- /dev/null +++ b/examples/array_of_partials_partial.js @@ -0,0 +1,3 @@ +var partial_context = { + numbers: [{i: '1'}, {i: '2'}, {i: '3'}, {i: '4'}] +}; diff --git a/examples/array_of_partials_partial.txt b/examples/array_of_partials_partial.txt new file mode 100644 index 0000000..f622375 --- /dev/null +++ b/examples/array_of_partials_partial.txt @@ -0,0 +1,5 @@ +Here is some stuff! +1 +2 +3 +4 diff --git a/mustache.js b/mustache.js index b6d60e4..b224249 100644 --- a/mustache.js +++ b/mustache.js @@ -89,7 +89,7 @@ var Mustache = function() { throw({message: "unknown_partial '" + name + "'"}); } if(typeof(context[name]) != "object") { - return partials[name]; + return this.render(partials[name], context, partials, true); } return this.render(partials[name], context[name], partials, true); },