Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created August 15, 2011 20:44
Show Gist options
  • Save guilleiguaran/1147806 to your computer and use it in GitHub Desktop.
Save guilleiguaran/1147806 to your computer and use it in GitHub Desktop.
CoffeeScript inside your views templates
# 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
@Indecrat
Copy link

Where did you find these tags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment