Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

here's the fix to make including .coffee files from .js.erb not require a raw #8

Merged
merged 1 commit into from
Jan 26, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/coffeebeans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ def self.erb_handler

def self.call(template)
compiled_source = erb_handler.call(template)
"::CoffeeScript.compile(begin;#{compiled_source};end)"
"::CoffeeScript.compile(begin;#{compiled_source};end).html_safe"
end
end
end

module ViewHelpers

def coffee_script_tag(&block)
content_tag(:script, coffee_script(&block), :type => 'text/javascript')
end

def coffee_script(&block)
::CoffeeScript.compile(capture(&block)).html_safe
end

end

end

ActionView::Template.register_template_handler :coffee, CoffeeBeans::Handlers::CoffeeScript
ActionView::Base.send :include, CoffeeBeans::ViewHelpers
ActionView::Base.send :include, CoffeeBeans::ViewHelpers