#237 ✓fixed_in_master_branch

Template.evaluate() eats 'before' character

Reported by Nir | July 24th, 2008 @ 02:53 PM | in 1.7

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?"


Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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.

Shared Ticket Bins