Class Sass::Script::Funcall
In: lib/sass/script/funcall.rb
Parent: Node
Haml::Util Engine Color SyntaxError UnitConversionError StandardError AbstractSequence CommaSequence Sequence SimpleSequence Simple Parent Universal Class SelectorPseudoClass Id Pseudo Attribute Interpolation Element Node Operation Literal UnaryOperation StringInterpolation Funcall Interpolation Variable Lexer CssLexer Number Bool String Parser Parser CssParser EvaluationContext StaticParser SassParser CssParser Node DebugNode IfNode CommentNode ForNode PropNode MixinNode CharsetNode DirectiveNode VariableNode WarnNode ExtendNode RootNode WhileNode MixinDefNode RuleNode Enumerable ImportNode Merb::BootLoader MerbBootLoader Repl CSS Environment Rack StalenessChecker lib/sass/repl.rb lib/sass/css.rb lib/sass/environment.rb lib/sass/error.rb lib/sass/engine.rb lib/sass/selector/simple_sequence.rb lib/sass/selector/abstract_sequence.rb lib/sass/selector/sequence.rb lib/sass/selector/comma_sequence.rb lib/sass/selector/simple.rb lib/sass/selector.rb Selector lib/sass/script/css_parser.rb lib/sass/script/lexer.rb lib/sass/script/color.rb lib/sass/script/string.rb lib/sass/script/unary_operation.rb lib/sass/script/variable.rb lib/sass/script/funcall.rb lib/sass/script/string_interpolation.rb lib/sass/script/operation.rb lib/sass/script/bool.rb lib/sass/script/parser.rb lib/sass/script/node.rb lib/sass/script/literal.rb lib/sass/script/interpolation.rb lib/sass/script/css_lexer.rb lib/sass/script/number.rb lib/sass/script/functions.rb Functions Script lib/sass/scss/sass_parser.rb lib/sass/scss/static_parser.rb lib/sass/scss/parser.rb lib/sass/scss/css_parser.rb ScriptLexer ScriptParser RX SCSS Callbacks Files lib/sass/tree/while_node.rb lib/sass/tree/if_node.rb lib/sass/tree/mixin_def_node.rb lib/sass/tree/debug_node.rb lib/sass/tree/root_node.rb lib/sass/tree/for_node.rb lib/sass/tree/import_node.rb lib/sass/tree/prop_node.rb lib/sass/tree/node.rb lib/sass/tree/comment_node.rb lib/sass/tree/extend_node.rb lib/sass/tree/charset_node.rb lib/sass/tree/mixin_node.rb lib/sass/tree/warn_node.rb lib/sass/tree/directive_node.rb lib/sass/tree/rule_node.rb lib/sass/tree/variable_node.rb Tree lib/sass/plugin/rack.rb lib/sass/plugin/staleness_checker.rb lib/sass/plugin/merb.rb Plugin Sass dot/m_86_0.png

A SassScript parse node representing a function call.

A function call either calls one of the functions in {Script::Functions}, or if no function with the given name exists it returns a string representation of the function call.

Methods

_perform   children   context=   inspect   new   to_sass  

Attributes

args  [R]  The arguments to the function.

@return [Array<Script::Node>]

name  [R]  The name of the function.

@return [String]

Public Class methods

@param name [String] See \{name} @param name [Array<Script::Node>] See \{args}

[Source]

    # File lib/sass/script/funcall.rb, line 32
32:       def initialize(name, args)
33:         @name = name
34:         @args = args
35:         super()
36:       end

Public Instance methods

Returns the arguments to the function.

@return [Array<Node>] @see Node#children

[Source]

    # File lib/sass/script/funcall.rb, line 52
52:       def children
53:         @args
54:       end

Don‘t set the context for child nodes if this is `url()`, since `url()` allows quoted strings.

@param context [Symbol] @see Node#context=

[Source]

    # File lib/sass/script/funcall.rb, line 26
26:       def context=(context)
27:         super unless @name == "url"
28:       end

@return [String] A string representation of the function call

[Source]

    # File lib/sass/script/funcall.rb, line 39
39:       def inspect
40:         "#{name}(#{args.map {|a| a.inspect}.join(', ')})"
41:       end

@see Node#to_sass

[Source]

    # File lib/sass/script/funcall.rb, line 44
44:       def to_sass(opts = {})
45:         "#{dasherize(name, opts)}(#{args.map {|a| a.to_sass(opts)}.join(', ')})"
46:       end

Protected Instance methods

Evaluates the function call.

@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [Literal] The SassScript object that is the value of the function call @raise [Sass::SyntaxError] if the function call raises an ArgumentError

[Source]

    # File lib/sass/script/funcall.rb, line 63
63:       def _perform(environment)
64:         args = self.args.map {|a| a.perform(environment)}
65:         ruby_name = name.gsub('-', '_')
66:         unless Haml::Util.has?(:public_instance_method, Functions, ruby_name) && ruby_name !~ /^__/
67:           opts(Script::String.new("#{name}(#{args.map {|a| a.perform(environment)}.join(', ')})"))
68:         else
69:           opts(Functions::EvaluationContext.new(environment.options).send(ruby_name, *args))
70:         end
71:       rescue ArgumentError => e
72:         raise e unless e.backtrace.any? {|t| t =~ /:in `(block in )?(#{name}|perform)'$/}
73:         raise Sass::SyntaxError.new("#{e.message} for `#{name}'")
74:       end

[Validate]