Created
July 27, 2011 03:19
-
-
Save davidjbeveridge/1108596 to your computer and use it in GitHub Desktop.
Script Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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