私は途方に暮れています。Ruby の経験が豊富な人が、何が起こっているのか教えてくれることを願っています。
次のように、スタイルシートからカスタム Sass 関数を呼び出しています。
$color: user_var('color')
カスタム関数は次のようになります。
module Sass::Script::Functions
def user_var(param_name)
puts options[:custom]
puts options[:custom].fetch('color')
puts options[:custom].fetch(param_name)
end
end
puts options[:custom]
(予想どおり)の結果は次のとおりです。
{"color"=>#eeeeee, "header"=>20px}
の結果puts options[:custom].fetch('color')
は #eeeeee です
しかし...結果のputs options[:custom].fetch(param_name)
結果は「キーが見つかりません: 'color' (KeyError)」です。
ここで完全に困惑。