From 0acab3dcd316c71de50cd10932c77df3a74a57e4 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 14 Nov 2011 14:04:13 -0500 Subject: [PATCH] Fixes #369 -- adding extra semicolons to templtes in case you forget. --- test/utility.js | 3 +++ underscore.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/utility.js b/test/utility.js index f1f0bfb56..0f53bd510 100644 --- a/test/utility.js +++ b/test/utility.js @@ -51,6 +51,9 @@ $(document).ready(function() { var result = basicTemplate({thing : 'This'}); equals(result, "This is gettin' on my noives!", 'can do basic attribute interpolation'); + var sansSemicolonTemplate = _.template("A <% this %> B"); + equals(sansSemicolonTemplate(), "A B"); + var backslashTemplate = _.template("<%= thing %> is \\ridanculous"); equals(backslashTemplate({thing: 'This'}), "This is \\ridanculous"); diff --git a/underscore.js b/underscore.js index 3737ddc1b..9aced7791 100644 --- a/underscore.js +++ b/underscore.js @@ -893,7 +893,7 @@ }) .replace(c.evaluate || null, function(match, code) { return "');" + code.replace(/\\'/g, "'") - .replace(/[\r\n\t]/g, ' ') + "__p.push('"; + .replace(/[\r\n\t]/g, ' ') + ";__p.push('"; }) .replace(/\r/g, '\\r') .replace(/\n/g, '\\n')