1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/sass/script.rb

61 lines
2.2 KiB
Ruby
Raw Normal View History

require 'strscan'
require 'sass/script/node'
require 'sass/script/variable'
require 'sass/script/funcall'
require 'sass/script/operation'
require 'sass/script/literal'
require 'sass/script/parser'
module Sass
# 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.
module Script
# The regular expression used to parse variables.
# @private
MATCH = /^[!\$](#{Sass::SCSS::RX::IDENT})\s*((?:\|\|)?[:=])\s*(.+)/
# The regular expression used to validate variables without matching.
# @private
VALIDATE = /^[!\$]#{Sass::SCSS::RX::IDENT}$/
# 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 options [{Symbol => Object}] An options hash;
# see {file:SASS_REFERENCE.md#sass_options the Sass options documentation}
# @return [Script::Node] The root node of the parse tree
def self.parse(value, line, offset, options = {})
Parser.parse(value, line, offset, options)
rescue Sass::SyntaxError => e
e.message << ": #{value.inspect}." if e.message == "SassScript error"
e.modify_backtrace(:line => line, :filename => options[:filename])
raise e
end
# @private
def self.var_warning(varname, line, offset, filename)
Haml::Util.haml_warn <<MESSAGE
DEPRECATION WARNING:
On line #{line}, character #{offset}#{" of '#{filename}'" if filename}
Variables with ! have been deprecated and will be removed in version 3.2.
Use \"$#{varname}\" instead.
2010-03-27 17:02:37 -07:00
MESSAGE
end
def self.equals_warning(types, name, val, line, offset, filename)
Haml::Util.haml_warn <<MESSAGE
2010-03-27 17:02:37 -07:00
DEPRECATION WARNING:
On line #{line}#{", character #{offset}" if offset}#{" of '#{filename}'" if filename}
Setting #{types} with = has been deprecated and will be removed in version 3.2.
Use "#{name}: #{val}" instead.
MESSAGE
end
end
end