Plugins - MinusMOR

StarAdd to favorites

For those who don’t quite buy the writing JavaScript in Ruby part of RJS and just want to write some real JavaScript. Here’s RJS minus the R. This tiny plugin simply adds .ejs templates accept normal JavaScript and ERB:

   alert('No more silly Ruby in my JavaScript!');
   $('thing').setStyle(<%=js @style_options %>);

And so on. Get the idea? As you can see above the plugin provided the built in js helper that simply calls to_json to turn your Ruby data into nice escaped strings. This version also has the partial() helper which takes a name of a partial (and any other options such as :collection, :locals) and renders out the HTML already escaped for you:

  $('boob').update(<%= partial('new_boob') %>);

This is a more liberal version of the original MinusR plugin which uses a new .ejs extension instead of completely overriding .rjs templates. This means that respond_to :js will now first search for a .ejs template and then revert to using a .rjs template if it’s not found. More kind and sharing you see?

Dan Webb

http://www.danwebb.net/2006/11/17/rjs-minus-r

http://svn.danwebb.net/external/rails/plugins/minus_mor/trunk/

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

View Extensions

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?