在Ruby中调用Sass的compile_file
我想调用 compile_file
来自我的 Ruby 文件中的 Sass。当我这样做时,
compile_file("file.scss", options)
我收到错误:未定义的方法'compile_file'。
我是否缺少require
或调用错误? Sass 已安装,当我在终端中启动它时,我可以让它正常观看。我希望能够在不观看时自己调用 compile_file
。有人可以给我示例代码,说明如何通过传入文件名和选项对象来在 Ruby 中使用 Sass 的 compile_file
吗?
I'd like to call compile_file
from Sass in my Ruby file. When I do
compile_file("file.scss", options)
I receive the error: undefined method 'compile_file.'
Am I missing a require
or calling it wrong? Sass is installed and I can have it watch properly when I start it in terminal. I'd like to be able to call compile_file
on my own when I'm not watching. Could someone give me example code on how to use Sass's compile_file
in Ruby by passing in a filename and an object for options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不了解 Sass,但一般来说,您需要使用方法的完全限定名称
Sass::compile_file
或要求模块进入全局空间:require 'sass'
>I don't know Sass, but in general you need to either use fully qualified name of the method
Sass::compile_file
or require the module into global space:require 'sass'
尝试类似的东西
Try something like
在使用
require 'sass'
之前安装 Sass:sudo gem install sass
现在创建一个文件
test.rb
:(do
chmod +x test.rb
)现在使用
colors.scss
:运行
./test.rb
将输出:根据 您应该使用的文档
Sass::Engine
:Install Sass before using
require 'sass'
:sudo gem install sass
Now create a file
test.rb
:(do
chmod +x test.rb
)Now with
colors.scss
:Running
./test.rb
will output:According the docs you should use
Sass::Engine
: