diff --git a/mustache.js b/mustache.js index a715c3b..a6e1fae 100644 --- a/mustache.js +++ b/mustache.js @@ -322,7 +322,7 @@ var Mustache = function() { return _context; } else { var iterator = "."; - if(this.pragmas["IMPLICIT-ITERATOR"]) { + if(this.pragmas["IMPLICIT-ITERATOR"] && this.pragmas["IMPLICIT-ITERATOR"].iterator) { iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator; } var ctx = {}; diff --git a/test/unit.js b/test/unit.js index a3ae7fb..eb3e2aa 100644 --- a/test/unit.js +++ b/test/unit.js @@ -389,7 +389,7 @@ test("'!' (Comments)", function() { }); test("'%' (Pragmas)", function() { - expect(2); + expect(3); // matches array_of_strings_options.html equals( @@ -417,6 +417,15 @@ test("'%' (Pragmas)", function() { } catch (e) { equals(e.message, 'This implementation of mustache doesn\'t understand the \'I-HAVE-THE-GREATEST-MUSTACHE\' pragma'); } + + equals( + Mustache.to_html( + '{{%IMPLICIT-ITERATOR}}{{#dataSet}}{{.}}:{{/dataSet}}', + { dataSet: [ 'Object 1', 'Object 2', 'Object 3' ] }, + {} + ), + "Object 1:Object 2:Object 3:" + ); }); test("Empty", function() {