headerizeA Rails plugin for including JS and stylesheets in templates but ensuring they appear in one place.
== Template Tags
Or, for show.html.haml:
- add_stylesheet ‘books’
If we also needed pages.js, we could do:
== Layout Tags
<%= stylesheet_link_tag 'application' %> <%= stylesheet_links %>
The returned strings are indented by four spaces by default. This can be modified by passing an indentation level:
<%= stylesheet_link_tag 'application' %> <%= stylesheet_links(:indent => 8) %> </head>
== Extra Options
Stylesheet tags can carry a media type other than screen – for example, for print media. The +add_stylesheet+ method supports this out of the box. In fact, invoking +add_stylesheet+ is exactly like invoking +stylesheet_link_tag+, only it will be included elsewhere. Thus, you can add the :media option to the end of the method:
<% add_stylesheets ‘print’, ‘more_print’, :media => ‘print’ %>
== License and Such
Headerize is Copyright © 2008 Antonio Salazar Cardozo, released under the MIT license.