Skip to content

Instantly share code, notes, and snippets.

@alg
Created February 25, 2010 23:46
Show Gist options
  • Save alg/315193 to your computer and use it in GitHub Desktop.
Save alg/315193 to your computer and use it in GitHub Desktop.
JS embedding
!!!
%html{ "xmlns" => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", "lang" => "en" }
%head
%meta{ "http-equiv" => "content-type", "content" => "text/html;charset=UTF-8" }
-# snip
= stylesheet_link_tag @additional_styles if @additional_styles
= javascript_include_tag @additional_scripts if @additional_scripts
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
# Adds stylesheets
def stylesheet(*names)
@additional_styles = (names + (@additional_styles || [])).uniq unless names.blank?
end
# Adds javascript files
def javascript(*names)
@additional_scripts = (names + (@additional_scripts || [])).uniq unless names.blank?
end
end
- stylesheet "admin/keywords", "admin/..."
- javascript "admin/keywords", "jquery-..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment