SassScript is code that‘s embedded in Sass documents to allow for property values to be computed from variables.
This module contains code that handles the parsing and evaluation of SassScript.
| VARIABLE_CHAR | = | ?! | The character that begins a variable. | |
| MATCH | = | /^!([a-zA-Z_]\w*)\s*((?:\|\|)?=)\s*(.+)/ | The regular expression used to parse variables. | |
| VALIDATE | = | /^![a-zA-Z_]\w*$/ | The regular expression used to validate variables without matching. |
Parses a string of SassScript
@param value [String] The SassScript @param line [Fixnum] The number of the line on which the SassScript appeared.
Used for error reporting
@param offset [Fixnum] The number of characters in on `line` that the SassScript started.
Used for error reporting
@param filename [String] The path to the file in which the SassScript appeared.
Used for error reporting
@return [Script::Node] The root node of the parse tree
# File lib/sass/script.rb, line 47
47: def self.parse(value, line, offset, filename = nil)
48: Parser.parse(value, line, offset, filename)
49: rescue Sass::SyntaxError => e
50: if e.message == "SassScript error"
51: e.instance_eval do
52: @message += ": #{value.dump}."
53: end
54: end
55: e.sass_line = line
56: raise e
57: end
Parses and evaluates a string of SassScript.
@param value [String] The SassScript @param line [Fixnum] The number of the line on which the SassScript appeared.
Used for error reporting
@param offset [Fixnum] The number of characters in on `line` that the SassScript started.
Used for error reporting
@param environment [Sass::Environment] The environment in which to evaluate the SassScript @return [String] The string result of evaluating the SassScript
# File lib/sass/script.rb, line 33
33: def self.resolve(value, line, offset, environment)
34: parse(value, line, offset).perform(environment).to_s
35: end