1

我想构建一个扩展来显示输入文件是否存在。

SCSS 示例:

@mixin generate-font-face($name, $source, $weight, $style) {
    @font-face {
        font-family: $name;
        font-weight: $weight;
        font-style: $style;

        @if file_exists("#{$source}.ttf") == true {
            // include
        }
    }
}

我的红宝石模块:

module Sass::Script::Functions
     # Does the supplied image exist?
     def file_exists(source)
        return Sass::Script::Bool.new(File.exists?(source.value))
     end
end

我的目录结构:

/scss/index.scss
/scss/font/droid.scss # << index.scss
/font/droid.ttf
/css/index.css # output
/lib/file.rb

示例调用:

@include generate-font-face("Droid Sans", "../font/droid", normal, normal);

但是我的扩展不起作用。

4

0 回答 0