Created
August 15, 2011 20:44
-
-
Save guilleiguaran/1147806 to your computer and use it in GitHub Desktop.
CoffeeScript inside your views templates
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
# coffee_script_tag | |
# Usage: | |
# | |
# <%= coffee_script_tag do %> | |
# alert 'Hello World' | |
# <% end %> | |
# | |
# | |
# You will get in your page: | |
# | |
# <script type="text/javascript"> | |
# (function() { | |
# alert('Hello World'); | |
# }).call(this); | |
# </script> | |
module ApplicationHelper | |
def coffee_script_tag(&block) | |
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where did you find these tags?