Method: Sass::Script::Functions#get_function
- Defined in:
- lib/sass/script/functions.rb
#get_function($name, $css: false) ⇒ Sass::Script::Value::Function
Returns a reference to a function for later invocation with the call() function.
If $css is false, the function reference may refer to a function
defined in your stylesheet or built-in to the host environment. If it's
true it will refer to a plain-CSS function.
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 |
# File 'lib/sass/script/functions.rb', line 1758
def get_function(name, kwargs = {})
assert_type name, :String, :name
css = if kwargs.has_key?("css")
v = kwargs.delete("css")
assert_type v, :Bool, :css
v.value
else
false
end
if kwargs.any?
raise ArgumentError.new("Illegal keyword argument '#{kwargs.keys.first}'")
end
if css
return Sass::Script::Value::Function.new(
Sass::Callable.new(name.value, nil, nil, nil, nil, nil, "function", :css))
end
callable = environment.caller.function(name.value) ||
(Sass::Script::Functions.callable?(name.value.tr("-", "_")) &&
Sass::Callable.new(name.value, nil, nil, nil, nil, nil, "function", :builtin))
if callable
Sass::Script::Value::Function.new(callable)
else
raise Sass::SyntaxError.new("Function not found: #{name}")
end
end
|