Template.evaluate() eats 'before' character
Reported by Nir | July 24th, 2008 @ 07:01 AM | in 1.6.1
Just a small bug in:
var Template = Class.create({
...
evaluate: function(object) {
if (Object.isFunction(object.toTemplateReplacements))
object = object.toTemplateReplacements();
return this.template.gsub(this.pattern, function(match) {
if (object == null) return '';
if a toTemplateReplacements() function ever returns null the gsub match function returns '' eating up the "before" character.
Here is a repro:
(a = {}).toTemplateReplacements = function () {return null;}
(new Template('Hi "#{name}", how are you?')).evaluate(a)
Outputs "Hi ", how are you?" instead of "Hi "", how are you?"
Nir
Comments and changes to this ticket
-

-
John-David Dalton July 24th, 2008 @ 02:53 PM
- → State changed from new to bug
-
John-David Dalton July 25th, 2008 @ 02:30 PM
- → Milestone changed from to 1.6.1
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
