1
我試圖在編譯時將Rails(3.2.12)的某些值傳遞給SASS(3.2.7)文件。我試圖按照SO上的SASS docs和其他一些answers。現在看來似乎應該是相當簡單,但我還沒有設法讓過去的這個錯誤:使用自定義函數將值從Rails傳遞給SASS
undefined method `gsub' for nil:NilClass
(in /home/joegatt/Sites/joegatt.net/v3/joegattnet_v3/app/assets/stylesheets/application.css.sass)
我的設置是:
#/config/application.rb
if config.respond_to?(:sass)
require "#{config.root}/lib/sass.rb"
end
#/lib/sass.rb
module Sass::Script::Functions
def styling(string, opts = {})
assert_type string, :String
Sass::Script::String.new('#ff0000')
end
declare :styling, :args => [:string]
end
#/assets/stylesheets/default.css.scss
background-color: styling('test')