From 180c02e641c3108bdd2e7da6f3a68a357c0a2b72 Mon Sep 17 00:00:00 2001 From: thegrandpoobah Date: Wed, 16 Jun 2010 17:23:22 -0400 Subject: [PATCH] ignore equal signs if not forming a set delimiter --- mustache.js | 2 +- test/unit.js | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/mustache.js b/mustache.js index 9e0ad63..797c7e7 100644 --- a/mustache.js +++ b/mustache.js @@ -174,7 +174,7 @@ var Mustache = function() { var that = this; var new_regex = function() { - return new RegExp(that.escaped_otag + "(!|>|\\{|&|%)?([^\\/#\\^]+?)\\1?" + + return new RegExp(that.escaped_otag + "(!|>|\\{|&|%)?([^\\/#\\^=]+?)\\1?" + that.escaped_ctag + "+", "g"); }; diff --git a/test/unit.js b/test/unit.js index e60dc40..fc030c2 100644 --- a/test/unit.js +++ b/test/unit.js @@ -1,5 +1,5 @@ test("Parser", function() { - expect(2); + expect(3); // matches whitespace_partial.html equals( @@ -38,6 +38,16 @@ test("Parser", function() { 'Hello\n\n\nWorld\n', 'Preservation of white space' ); + + equals( + Mustache.to_html( + '{{=tag1}}', + { tag1: 'Hello' }, + {} + ), + '{{=tag1}}', + 'ignore equal sign' + ); }); test("Basic Variables", function() { @@ -248,7 +258,7 @@ test("'^' (Inverted Section)", function() { }); test("'>' (Partials)", function() { - expect(4); + expect(5); // matches view_partial.html equals( @@ -327,6 +337,17 @@ test("'>' (Partials)", function() { ), '1\n1.1\n1.1.1\n\n\n' ); + + try { + Mustache.to_html( + '{{>partial}}', + {}, + {partal: ''} + ); + ok(false); + } catch(e) { + equals(e.message, "unknown_partial 'partial'"); + } }); test("'=' (Set Delimiter)", function() {