Skip to content

Instantly share code, notes, and snippets.

@davidjbeveridge
Created July 27, 2011 03:19
Show Gist options
  • Save davidjbeveridge/1108596 to your computer and use it in GitHub Desktop.
Save davidjbeveridge/1108596 to your computer and use it in GitHub Desktop.
Script Helper
module ScriptHelper
def extra_script(script)
@extra_scripts ||= []
@extra_scripts << script
end
def extra_scripts
if @extra_scripts
scripts = @extra_scripts.map {|script| javascript_include_tag script}
scripts.join("\n").html_safe
end
end
# Just do <%= extra_scripts %> somewhere inside <head>
# Then you can use <% extra_script 'myscript' %> anywhere and it will queue the script =)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment