How do I call a sass function from inside a ruby file?
The following line works in the command prompt:
sass C:\Users\..etc..\main.scss
I need to put this into a Ruby file. So I wrote as below in a Ruby file:
require 'sass'
$arg1 = 'C:/Users/dmoores/Desktop/testst/main.scss'
sass $arg1
But it complains with the following:
undefined method `sass' for main:Object (NoMethodError)
Set the options as you need, then use Sass::Engine#render
.
require "sass"
options = {
cache: true,
syntax: :sass,
style: :compressed,
filename: original_file_name,
...
}
render = Sass::Engine.new(File.read(original_file_name), options).render
File.write(output_file_name, render)
This documentation should help:
http://sass-lang.com/documentation/file.SASS_REFERENCE.html
If you've already installed the Sass gem, you can run it from the Command Line. To use Sass in your ruby script, you need to make a Sass object and then use the functions associated with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With