How do I load extensions to the Sass::Script::Functions module?

前端 未结 2 386
旧巷少年郎
旧巷少年郎 2021-01-14 00:11

I\'m trying to extend the Sass:Script::Functions module, per this recommendation: https://gist.github.com/481261/dd07a52829886ab1ad0875a8895f0100c4b925ab. The question is, w

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-14 00:30

    I usually make a folder in lib named "sass" and in that folder create a sass-hex.rb (make sure this folder is on the load path)

    module Sass::Script::Functions
      module SassHex
        def hex(decimal)
          Sass::Script::String.new("%02x" % decimal)
        end
      end
      include SassHex
    end
    

    All you should have todo is require the sass-hex.rb file I use this trick a lot in compass when extending sass.

提交回复
热议问题