This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
shadowfiend (author)
Sat Jun 07 09:19:12 -0700 2008
commit 12e81630c4622065aeb9a87e3435c79868d2cb56
tree 5f7c7832b7165da50750b9d390df5a143c01e08b
parent 6c76acc49e460dd9ed04644f6ba06119e2653839
tree 5f7c7832b7165da50750b9d390df5a143c01e08b
parent 6c76acc49e460dd9ed04644f6ba06119e2653839
README
= Headerize
Headerize is a Rails plugin to allow including Javascript and CSS from within
your templates, but still have these appear in your HTML's <head> section (as
$DEITY intended it). It provides a set of helpers that facilitate this and can
be used in the layout (for outputting the JS and CSS includes) and templates
(for adding JS and CSS includes to the head).
== Template Tags
In your templates, you can use the two methods +add_stylesheet+ and
+add_javascript+. These are aliased to +add_stylesheets+ and +add_javascripts+
for adding multiple scripts or stylesheets, respectively. Thus, if one had a
+BooksController+ whose +show+ method needed the <tt>books.css</tt> stylesheet
and the <tt>books.js</tt> javascript file, at the top of show.html.erb, we would
put:
<% add_stylesheet 'books'
add_javascript 'books %>
Or, for show.html.haml:
- add_stylesheet 'books'
- add_javascript 'books'
If we also needed pages.js, we could do:
add_javascript 'books', 'pages'
== Layout Tags
In the layout, within the head, two methods will spit out the accumulated
stylesheets for this view: +stylesheet_links+ and +javascript_includes+. So, the
layout for the above might have:
<html>
<head>
<%= javascript_include_tag :defaults %>
<%= javascript_includes %>
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_links %>
</head>
...
The returned strings are indented by four spaces by default. This can be
modified by passing an indentation level:
<html>
<head>
<%= javascript_include_tag :defaults %>
<%= javascript_includes(:indent => 8) %>
<%= 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' %>
The same is true of +add_javascript+. This means that, if you want to use Rails
2.1's caching, you can do this, too:
<% add_javascripts 'books', 'pages', :cache => true %>
== License and Such
Headerize is Copyright (c) 2008 Antonio Salazar Cardozo, released under the MIT
license.








