From 368b4c30def048dac85dabf5a546cda88309b1da Mon Sep 17 00:00:00 2001 From: Sahab Yazdani Date: Mon, 4 Jul 2011 14:21:43 -0400 Subject: [PATCH] Missing global flag on regex in pragma interpreter --- mustache.js | 2 +- test/unit.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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' ); });