Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Ruby style string injection via Prototype Templates (See related posts)

Requires Prototype 1.5

I'm honestly not sure why they didn't do this out of the box.

Object.extend(String.prototype, {
  mixin: function(obj) {
    return new Template(this).evaluate(obj);
  }
});


Oh, yes.

"#{company} forever!".mixin({company: 'Unspace'}) // Unspace forever!

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts