How do I take a string of SCSS and have it output CSS?
ruby, ruby-on-rails, sass
Solution
Just do:
# your SCSS string
str = %Q{
$text-color: #555555;
$unfocused-background-color: #f1f0ec;
body {
background: $unfocused-background-color;
color: $text-color;
}
}
se = Sass::Engine.new(str, :syntax => :scss)
se.render
# => "body {\n background: #f1f0ec;\n color: #555555; }\n"
See the Sass reference docs here: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html.
Problem
I have templates in my application that have their own style sheets. I'd like to let my users (and myself) take advantage of SCSS features. However, I haven't been able to find out how to send the `Sass` gem a string of SCSS, and have it return regular CSS. (I also haven't been able to find it on google, nor is it easy to find in the documentation.) So how do I do it?