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
        }
    }
}

私のRubyモジュール:

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