-
-
Save avit/81534 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Set up rendering of sass through ERB in ActionView | |
require 'ersass_template_handler' | |
ActionView::Template.register_template_handler :sass, ActionView::TemplateHandlers::ErSass | |
ActionView::Template.exempt_from_layout :sass |
This file contains hidden or 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
## Preprocess SASS templates through ERB | |
module ActionView | |
module TemplateHandlers | |
class ErSass < TemplateHandler | |
include Compilable | |
def initialize(view=nil) | |
@view = view | |
end | |
def compile(template) | |
<<-END.gsub("\n", ";") | |
controller.headers['Content-Type'] = 'text/css' | |
controller.headers['Cache-Control'] = 'max-age=86400 public' | |
__in_erb_template = true | |
erbout = eval(ERB.new(template.source).src) | |
@output_buffer = Sass::Engine.new(erbout, Sass::Plugin.engine_options).render | |
END | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment