t?gr(0,e+t):hr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=U,u.noConflict=function(){return n._=X,this},u.random=function(n,r){return n==G&&r==G&&(r=1),n=+n||0,r==G&&(r=n,n=0),n+or(yr()*((+r||0)-n+1))
+},u.reduce=R,u.reduceRight=T,u.result=function(n,r){var t=n?n[r]:G;return m(t)?n[r]():t},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Fr(n).length},u.some=q,u.sortedIndex=I,u.template=function(n,r,t){n||(n=""),t=g({},t,u.templateSettings);var e=0,o="__p+='",i=t.variable;n.replace(RegExp((t.escape||nr).source+"|"+(t.interpolate||nr).source+"|"+(t.evaluate||nr).source+"|$","g"),function(r,t,u,i,f){return o+=n.slice(e,f).replace(tr,a),t&&(o+="'+_['escape']("+t+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=f+r.length,r
+}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var f=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return r?f(r):(f.source=o,f)},u.unescape=function(n){return n==G?"":(n+"").replace(Y,s)},u.uniqueId=function(n){var r=++Q+"";return n?n+r:r},u.all=x,u.any=q,u.detect=O,u.foldl=R,u.foldr=T,u.include=A,u.inject=R,u.first=B,u.last=function(n,r,t){if(n){var e=0,u=n.length;
+if(typeof r=="function"){var o=u;for(r=i(r,t);o--&&r(n[o],o,n);)e++}else if(e=r,e==G||t)return n[u-1];return l(n,gr(0,u-e))}},u.take=B,u.head=B,u.chain=function(n){return n=new u(n),n.__chain__=V,n},u.VERSION="1.0.0-rc.3",U(u),u.prototype.chain=function(){return this.__chain__=V,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var r=L[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Er&&0===n.length&&delete n[0],this
+}}),e(["concat","join","slice"],function(n){var r=L[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=V),n}}),J?typeof module=="object"&&module&&module.exports==J?(module.exports=u)._=u:J._=u:n._=u})(this);
\ No newline at end of file
diff --git a/test/test.js b/test/test.js
index 698a2ab31..e347199fb 100644
--- a/test/test.js
+++ b/test/test.js
@@ -2090,6 +2090,16 @@
equal(compiled(data), 'a');
});
+ test('should work with "interpolate" delimiters containing global values', function() {
+ var compiled = _.template('<%= typeof QUnit.init %>');
+
+ try {
+ var actual = compiled();
+ } catch(e) { }
+
+ equal(actual, 'function');
+ });
+
test('should parse delimiters with newlines', function() {
var expected = '<<\nprint("" + (value ? "yes" : "no") + "
")\n>>',
compiled = _.template(expected, null, { 'evaluate': /<<(.+?)>>/g }),