diff --git a/CHANGES.md b/CHANGES.md index 7208204..01d3044 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ * Added more robust type detection. * Parse pragmas only once. * Throw exception when encountering an unknown pragma. +* Ignore undefined partial contexts. Returns verbatim partials. ## 0.2.2 (11-02-2010) diff --git a/examples/empty_partial.2.html b/examples/empty_partial.2.html new file mode 100644 index 0000000..b920295 --- /dev/null +++ b/examples/empty_partial.2.html @@ -0,0 +1 @@ +yo \ No newline at end of file diff --git a/examples/empty_partial.html b/examples/empty_partial.html new file mode 100644 index 0000000..a710047 --- /dev/null +++ b/examples/empty_partial.html @@ -0,0 +1,2 @@ +hey {{foo}} +{{>partial}} diff --git a/examples/empty_partial.js b/examples/empty_partial.js new file mode 100644 index 0000000..9cc53c6 --- /dev/null +++ b/examples/empty_partial.js @@ -0,0 +1,3 @@ +var partial_context = { + foo: 1 +}; diff --git a/examples/empty_partial.txt b/examples/empty_partial.txt new file mode 100644 index 0000000..90d2b9f --- /dev/null +++ b/examples/empty_partial.txt @@ -0,0 +1,2 @@ +hey 1 +yo diff --git a/mustache.js b/mustache.js index 25d8390..eab1a9f 100644 --- a/mustache.js +++ b/mustache.js @@ -85,12 +85,12 @@ var Mustache = function() { Tries to find a partial in the global scope and render it */ render_partial: function(name, context, partials) { - if(typeof(context[name]) != "object") { - throw({message: "subcontext for '" + name + "' is not an object"}); - } if(!partials || !partials[name]) { throw({message: "unknown_partial '" + name + "'"}); } + if(typeof(context[name]) != "object") { + return partials[name]; + } return this.render(partials[name], context[name], partials, true); },