diff --git a/mustache.js b/mustache.js index 722d069..c88082b 100644 --- a/mustache.js +++ b/mustache.js @@ -273,7 +273,7 @@ var Mustache = (function(undefined) { return state.template; } - state.template = state.template.replace(/{{%([\w-]+)(\s*)(.*?(?=}}))}}/, function(match, pragma, space, suffix) { + state.template = state.template.replace(/{{%([\w-]+)(\s*)(.*?(?=}}))}}/g, function(match, pragma, space, suffix) { var options = undefined, optionPairs, scratch, i, n; diff --git a/test/unit.js b/test/unit.js index d1bd0c4..84b23b0 100644 --- a/test/unit.js +++ b/test/unit.js @@ -511,6 +511,21 @@ test("'%' (Pragmas)", function() { ), "Object 1:Object 2:Object 3:", 'Change Delimiter and Pragma mixes' + ); + + + raises( + function() { + Mustache.to_html( + '{{%IMPLICIT-ITERATOR iterator=rob}}{{%I-HAVE-THE-GREATEST-MUSTACHE}}', + {}, + {} + ); + }, + function(e) { + return e.message === 'This implementation of mustache does not implement the "I-HAVE-THE-GREATEST-MUSTACHE" pragma.'; + }, + 'Multiple Pragmas' ); });