I'm at a loss. Hoping somebody with more Ruby experience will tell me what is going on.
I'm calling a custom Sass function from my stylesheet like so:
$color: user_var('color')
The custom function looks like this:
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
The result of puts options[:custom]
(as expected) is this:
{"color"=>#eeeeee, "header"=>20px}
The result of puts options[:custom].fetch('color')
is #eeeeee
BUT... the result of puts options[:custom].fetch(param_name)
results in a "key not found: 'color' (KeyError)".
Completely baffled here.
my guess is that param_name is a symbol and the color key in the options hash is defined as a string.
this should work.
options[:custom].fetch("#{param_name}")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.