Permalink
Browse files

Remove the equals context and the sass2 mode from sass-convert.

  • Loading branch information...
chriseppstein committed Mar 11, 2011
1 parent ffd0090 commit 7cbb4b90fcf5f65436c8caebbed1f0face95db48
@@ -309,11 +309,6 @@ Available options are:
: An option that's available for individual applications to set
to make data available to {Sass::Script::Functions custom Sass functions}.
-{#sass2-option} `:sass2`
-: Parses the document using semantics closer to that of Sass v2.
- Currently, this just means that strings in mixin arguments
- are treated as though they were in [an `=` context](#sass-script-strings).
-
{#quiet-option} `:quiet`
: When set to true, causes warnings to be disabled.
View
@@ -447,12 +447,11 @@ def set_opts(opts)
END
opts.on('-F', '--from FORMAT',
- 'The format to convert from. Can be css, scss, sass, less, or sass2.',
- 'sass2 is the same as sass, but updates more old syntax to new.',
+ 'The format to convert from. Can be css, scss, sass, less.',
'By default, this is inferred from the input filename.',
'If there is none, defaults to css.') do |name|
@options[:from] = name.downcase.to_sym
- unless [:css, :scss, :sass, :less, :sass2].include?(@options[:from])
+ unless [:css, :scss, :sass, :less].include?(@options[:from])
raise "Unknown format for sass-convert --from: #{name}"
end
try_less_note if @options[:from] == :less
@@ -536,14 +535,12 @@ def process_directory
@options[:output] ||= @options[:input]
from = @options[:from]
- from = :sass if from == :sass2
if @options[:to] == @options[:from] && !@options[:in_place]
fmt = @options[:from]
raise "Error: converting from #{fmt} to #{fmt} without --in-place"
end
ext = @options[:from]
- ext = :sass if ext == :sass2
Dir.glob("#{@options[:input]}/**/*.#{ext}") do |f|
output =
if @options[:in_place]
@@ -594,11 +591,6 @@ def process_file(input, output)
end
end
- if @options[:from] == :sass2
- @options[:from] = :sass
- @options[:for_engine][:sass2] = true
- end
-
@options[:from] ||= :css
@options[:to] ||= :sass
@options[:for_engine][:syntax] = @options[:from]
@@ -23,15 +23,6 @@ class Funcall < Node
# @return [{String => Script::Node}]
attr_reader :keywords
- # Don't set the context for child nodes if this is `url()`,
- # since `url()` allows quoted strings.
- #
- # @param context [Symbol]
- # @see Node#context=
- def context=(context)
- super unless @name == "url"
- end
-
# @param name [String] See \{#name}
# @param args [Array<Script::Node>] See \{#args}
# @param keywords [{String => Script::Node}] See \{#keywords}
View
@@ -61,7 +61,6 @@ def _perform(environment)
value.map {|e| e.perform(environment)},
separator)
list.options = self.options
- list.context = self.context
list
end
View
@@ -8,18 +8,6 @@ class Node
# @return [{Symbol => Object}]
attr_reader :options
- # The context in which this node was parsed,
- # which determines how some operations are performed.
- #
- # Can be `:equals`, which means it's part of a `$var = val` or `prop = val` assignment,
- # or `:default`, which means it's anywhere else
- # (including `$var: val` and `prop: val` assignments,
- # `#{}`-interpolations,
- # and other script contexts such as `@if` conditions).
- #
- # @return [Symbol]
- attr_reader :context
-
# The line of the document on which this node appeared.
#
# @return [Fixnum]
@@ -41,21 +29,6 @@ def options=(options)
end
end
- # Sets the context for this node,
- # as well as for all child nodes.
- #
- # @param context [Symbol]
- # @see #context
- def context=(context)
- @context = context
- children.each {|c| c.context = context}
- end
-
- # Creates a new script node.
- def initialize
- @context = :default
- end
-
# Evaluates the node.
#
# \{#perform} shouldn't be overridden directly;
@@ -149,7 +149,7 @@ def times(other)
def div(other)
if other.is_a? Number
res = operate(other, :/)
- if self.original && other.original && context != :equals
+ if self.original && other.original
res.original = "#{self.original}/#{other.original}"
end
res
@@ -66,11 +66,6 @@ def _perform(environment)
literal1 = @operand1.perform(environment)
literal2 = @operand2.perform(environment)
- if @operator == :space && context == :equals
- literal1 = Sass::Script::String.new(literal1.value) if literal1.is_a?(Sass::Script::String)
- literal2 = Sass::Script::String.new(literal2.value) if literal2.is_a?(Sass::Script::String)
- end
-
begin
opts(literal1.send(@operator, literal2))
rescue NoMethodError => e
View
@@ -15,15 +15,6 @@ class String < Literal
# @return [Symbol] `:string` or `:identifier`
attr_reader :type
- # In addition to setting the \{#context} of the string,
- # this sets the string to be an identifier if the context is `:equals`.
- #
- # @see Node#context=
- def context=(context)
- super
- @type = :identifier if context == :equals
- end
-
# Creates a new string.
#
# @param value [String] See \{#value}
@@ -42,7 +33,7 @@ def plus(other)
# @see Node#to_s
def to_s(opts = {})
if @type == :identifier
- return @context == :equals && @value.empty? ? %q{""} : @value.tr("\n", " ")
+ return @value.tr("\n", " ")
end
return "\"#{value.gsub('"', "\\\"")}\"" if opts[:quote] == %q{"}
@@ -54,13 +45,7 @@ def to_s(opts = {})
# @see Node#to_sass
def to_sass(opts = {})
- if self.type == :identifier && context == :equals &&
- self.value !~ Sass::SCSS::RX::URI &&
- Sass::SCSS::RX.escape_ident(self.value).include?(?\\)
- return "unquote(#{Sass::Script::String.new(self.value, :string).to_sass})"
- else
- return to_s
- end
+ to_s
end
end
end
@@ -23,6 +23,7 @@ def inspect
# @see Node#to_sass
def to_sass(opts = {})
# We can get rid of all of this when we remove the deprecated :equals context
+ # XXX CE: It's gone now but I'm not sure what can be removed now.
before_unquote, before_quote_char, before_str = parse_str(@before.to_sass(opts))
after_unquote, after_quote_char, after_str = parse_str(@after.to_sass(opts))
unquote = before_unquote || after_unquote ||
@@ -19,13 +19,6 @@ class MixinNode < Node
# @return [{String => Script::Node}]
attr_reader :keywords
- # @see Node#options=
- def options=(opts)
- super
- @args.each {|a| a.context = :equals} if opts[:sass2]
- @keywords.each {|k, v| v.context = :equals} if opts[:sass2]
- end
-
# @param name [String] The name of the mixin
# @param args [Array<Script::Node>] See \{#args}
# @param keywords [{String => Script::Node}] See \{#keywords}
@@ -143,7 +143,7 @@ def val_to_sass_div(node, opts)
unless node.is_a?(Sass::Script::Operation) && node.operator == :div &&
node.operand1.is_a?(Sass::Script::Number) &&
node.operand2.is_a?(Sass::Script::Number) &&
- (node.context == :equals || !node.operand1.original || !node.operand2.original)
+ (!node.operand1.original || !node.operand2.original)
return node
end
@@ -191,11 +191,7 @@ def visit_mixin(node)
elsif kv = passed_keywords[var.underscored_name]
kv.perform(env)
elsif default
- val = default.perform(env)
- if default.context == :equals && val.is_a?(Sass::Script::String)
- val = Sass::Script::String.new(val.value)
- end
- val
+ default.perform(env)
end)
raise Sass::SyntaxError.new("Mixin #{node.name} is missing parameter #{var.inspect}.") unless env.var(var.name)
env
@@ -217,12 +213,7 @@ def visit_mixin(node)
def visit_prop(node)
node.resolved_name = run_interp(node.name)
val = node.value.perform(@environment)
- node.resolved_value =
- if node.value.context == :equals && val.is_a?(Sass::Script::String)
- val.value
- else
- val.to_s
- end
+ node.resolved_value = val.to_s
yield
end
@@ -243,7 +234,6 @@ def visit_rule(node)
def visit_variable(node)
return [] if node.guarded && !@environment.var(node.name).nil?
val = node.expr.perform(@environment)
- val = Sass::Script::String.new(val.value) if node.expr.context == :equals && val.is_a?(Sass::Script::String)
@environment.set_var(node.name, val)
[]
end
@@ -269,30 +269,6 @@ def test_string_interpolation
assert_equal '"foo#{$bar}baz"', render("'foo\#{$bar}baz'")
end
- def test_sass2_string_interpolation
- assert_equal 'foo#{$bar}baz', render('"foo#{$bar}baz"', :context => :equals)
- assert_equal '#{$bar}baz', render('"#{$bar}baz"', :context => :equals)
- assert_equal 'foo#{$bar}', render('"foo#{$bar}"', :context => :equals)
-
- assert_equal 'unquote(".foo#{$bar}.bar")', render('".foo#{$bar}.bar"', :context => :equals)
- assert_equal 'unquote(".foo#{$bar}")', render('".foo#{$bar}"', :context => :equals)
- assert_equal 'unquote("#{$bar}.bar")', render('"#{$bar}.bar"', :context => :equals)
-
- assert_equal "unquote(\"f'o\#{$bar}b'z\")", render("'f\\'o\#{$bar}b\\'z'", :context => :equals)
- assert_equal "unquote('f\"o\#{$bar}b\"z')", render("'f\\\"o\#{$bar}b\\\"z'", :context => :equals)
- assert_equal "unquote(\"f'o\#{$bar}b\\\"z\")", render("'f\\'o\#{$bar}b\\\"z'", :context => :equals)
- end
-
- def test_sass2_urls
- Sass::Util.silence_sass_warnings do
- assert_equal 'url(foo/bar.gif)', render('url(foo/bar.gif)', :context => :equals)
- assert_equal 'url("foo/bar.gif")', render('url("foo/bar.gif")', :context => :equals)
-
- assert_equal 'url($var)', render('url($var)', :context => :equals)
- assert_equal 'url("#{$var}/flip.gif")', render('url("#{$var}/flip.gif")', :context => :equals)
- end
- end
-
private
def assert_renders(script, options = {})
@@ -302,7 +278,6 @@ def assert_renders(script, options = {})
def render(script, options = {})
munge_filename(options)
node = Sass::Script.parse(script, 1, 0, options)
- node.context = options[:context] if options[:context]
node.to_sass
end
end

0 comments on commit 7cbb4b9

Please sign in to comment.