diff --git a/CHANGELOG b/CHANGELOG index 076be7e..59b8f25 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,13 @@ -*1.6.0_rc1* (October 16, 2007) +*SVN* + +* Fix template evaluation with empty replacements. Closes #9692. [Ryan McGeary] * Hash#toTemplateReplacements is an alias for Hash#toObject so you can once again pass hashes to Template#evaluate and String#interpolate. [sam] * Fix Event#is(Left|Middle|Right)Click in IE. Closes #7520 (again). [Mislav Marohnić] +*1.6.0_rc1* (October 16, 2007) + * Ensure Event.* generic methods work in IE, even when the event is not extended. [Viktor Kojouharov, Andrew Dupont] * Don't translate "keypress" events into "keydown" events. [sam] diff --git a/src/string.js b/src/string.js index 0a994e2..ff89433 100644 --- a/src/string.js +++ b/src/string.js @@ -246,7 +246,7 @@ var Template = Class.create({ var ctx = object, expr = match[3]; var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr); - if (match == null) return ''; + if (match == null) return before; while (match != null) { var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; diff --git a/test/unit/string.html b/test/unit/string.html index 9241e52..023b5bb 100644 --- a/test/unit/string.html +++ b/test/unit/string.html @@ -305,6 +305,15 @@ template.evaluate({})); }}, + testTemplateEvaluationWithEmptyReplacement: function() {with(this) { + var template = new Template('##{}'); + assertEqual('#', template.evaluate({})); + assertEqual('#', template.evaluate({foo: 'bar'})); + + template = new Template('#{}'); + assertEqual('', template.evaluate({})); + }}, + testTemplateEvaluationWithFalses: function() {with(this) { var source = '