Skip to content

Instantly share code, notes, and snippets.

@stouset
Created October 13, 2010 21:36
Show Gist options
  • Save stouset/624962 to your computer and use it in GitHub Desktop.
Save stouset/624962 to your computer and use it in GitHub Desktop.
class ActionView::Template::Handlers::Sass < ActionView::Template::Handler
include ActionView::Template::Handlers::Compilable
def compile(template)
engine = Sass::Engine.new template.source, options(template)
<<-VCJMIOEP
<<-QCGQCEWG
#{engine.render}
QCGQCEWG
VCJMIOEP
end
def syntax(filename)
case filename
when %r{\.scss$} then :scss
when %r{\.sass$} then :sass
end
end
def options(template)
Sass::Plugin.engine_options :syntax => syntax(template.identifier)
end
def handles_encoding?
true
end
end
ActionView::Template.register_template_handler :sass,
ActionView::Template::Handlers::Sass
ActionView::Template.register_template_handler :scss,
ActionView::Template::Handlers::Sass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment