Monday, April 7, 2008

Merb-Assets

The gem is merb-assets.

In order to take advantage of the merb-assets you need to modify your config/init.rb and add:
dependencies "merb-assets"

Now you can use link to:
link_to("Home","/home/index")

If you have a :home route defined, you can:
link_to("Home",:home)


For your css and javascripts you have the following:
  <%= css_include_tag 'reset.css', 'master.css', 'jquery.treeview.css', :bundle => true %>

<%= js_include_tag 'jquery-1.2.3.pack', 'jquery.cookie.js', 'jquery.treeview.pack.js', 'application.js', :bundle => true %>


The cool thing about this is that, in production mode, this assets get combined into a single file. So you'll end up with an all.css and and all.js. You can specify the name of the bundle:
  <%= css_include_tag 'reset.css', 'master.css', 'forms.css', 'jquery.treeview.css', :bundle => :base %>

<%= js_include_tag 'jquery-1.2.3.pack', 'jquery.cookie.js', 'jquery.treeview.pack.js', 'application.js', :bundle => :base %>


This will create a base.js and base.css to be included. Nice.

More info to be added as I come across asset oriented features.

back to Merb index

0 comments: