Maybe I'm completely off, and I haven't touched Proto in over a month (!?!!*),
But what about declaring a toTemplateReplacements in the object? (the
following is untested)
MyClass = Class.create({
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 },
toTemplateReplacements: function() {
return { first: this.first(), second: this.second(), third: this.third() }
}
});
var obj = new MyClass(1, 2, 3);
"Hey, I'm #{first}, i'm #{second} and I'm #{third}".interpolate(obj);
//=> "Hey, I'm 1, I'm 2 and I'm 3"
That's supposedly the use of toTemplateReplacements :)
Best,
-Nicolas
*PS: my new job working full time with rails is great, though I miss
hacking stuff with proto :)
On Wed, Mar 5, 2008 at 9:18 PM, J. Gregory Wright <[EMAIL PROTECTED]> wrote:
>
> On Mar 5, 5:38 pm, kangax <[EMAIL PROTECTED]> wrote:
> > > The problem is that the toString() operation called on an object of
> > > type Function returns the literal string source of the function.
> >
> > Unless we redefine it (which is what the previous example is about)
>
> Hmmmm, there's something to ponder... although the thought of
> overriding it globally makes me wonder what might break as a result of
> doing so... with my luck, the answer would be "lotsa stuff". :)
>
>
> > > I'm not sure that I see where checking the type is limiting - if it is
> > > a function, apply it with the current object; if it is not send it
> > > through the usual interpretation.
> >
> > I guess it's just a matter of taste : )
>
> I'll buy that... I'm no JavaScript (much less Prototype) expert, so I
> was concerned that I might be missing something fundamental where
> manipulating objects was concerned.
>
> Gracias,
>
>
> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---