How to take SCSS string and display it?

I have templates in my application that have their own stylesheets. I want my users (and I) to use SCSS features. However, I was unable to find out how to send the Sass gem SCSS string and return normal CSS to it.

(I also could not find it on google and it is not easy to find in the documentation.)

So how do I do this?

+4
source share
1 answer

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 .

+10
source

Source: https://habr.com/ru/post/1495808/


All Articles