diff --git a/CHANGELOG b/CHANGELOG index 4e42982..076be7e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *1.6.0_rc1* (October 16, 2007) +* 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ć] * Ensure Event.* generic methods work in IE, even when the event is not extended. [Viktor Kojouharov, Andrew Dupont] diff --git a/src/hash.js b/src/hash.js index 326cb0e..dc0e905 100644 --- a/src/hash.js +++ b/src/hash.js @@ -116,4 +116,5 @@ var Hash = Class.create(Enumerable, (function() { } })()); -Hash.from = $H; \ No newline at end of file +Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; +Hash.from = $H; diff --git a/test/unit/hash.html b/test/unit/hash.html index 7c283e8..ec214e8 100644 --- a/test/unit/hash.html +++ b/test/unit/hash.html @@ -206,6 +206,13 @@ assertEnumEqual($w('_each keys map pluck unset'), h.keys().sort()); assertEqual('U', h.unset('unset')); assertHashEqual({ _each: 'E', map: 'M', keys: 'K', pluck: 'P' }, h); + }}, + + testHashToTemplateReplacements: function() { with(this) { + var template = new Template("#{a} #{b}"), hash = $H({ a: "hello", b: "world" }); + assertEqual("hello world", template.evaluate(hash.toObject())); + assertEqual("hello world", template.evaluate(hash)); + assertEqual("hello", "#{a}".interpolate(hash)); }} }, 'testlog');