If I have [admittedly simple] code as follows:

MyClass = Class.create({
  _a: false,

  _ b: false,

  _c: false,

  initialize: function(a, b, c) {
    this._a = a;
    this._b = b;
    this._c = c;
  },

  first: function(){
    return this._a;
  },

  second: function(){
    return this._b;
  },

  third: function(){
    return this._c;
  }
});

var myObj = new MyClass('A','B','C');
var myTmpl = new Template('First: #{first}, Second: #{second}, Third:
#{third}');
var myOut = myTmpl.evaluate(myObj);

Then the string value placed in myOut will not be:

"First: A, Second: B, Third: C"

but rather will be:

"First: function(){
    return this._a;
  }, Second: function(){
    return this._b;
  }, Third:function(){
    return this._c;
  }"

Based on the code for Template#evaluate, it would seem that the line:

return before + String(ctx);

could be replaced by:

return before + (Object.isFunction(ctx)) ? ctx.apply(object) :
String(ctx);

and produce [the/my] desired effect of rendering the return value from
the function instead of the function literal. Is there a reason why
this would not be workable, or should not be done?

Thanks in advance,
G
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to