简体   繁体   中英

Evaluate SCSS (SASS) templates in ruby (Rails project)

I am working on a sort of CMS project where I am leveraging SCSS. I would like to allow the user to specify properties of a stylesheet in a simple way (enable a few color customization), and then generate a CSS file based on SCSS templates, and substitute some variables in the SCSS file using mustache or ERB evaluation.

Basically, I want an ERB file to be rendered as scss file, and then generate a css in my application, upload it to S3, and include in the user's layout. If possible I would like to avoid using css.erb files :-)

I fact (I am answering my own question). What I am trying to do is really easy. I've made this really simple script:

#!/usr/bin/env ruby

#processs.rb file

require 'sass'
result = Sass.compile open(ARGV[0]).read
puts result

And it generates css out of a scss file she invoked like this:

ruby process.rb myfile.css.scss

And this works perfectly. The code documentation in sass source code helped me to find this out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM