mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] [css2sass] Automatically backslash-escape pseudo-classes.
Closes gh-51
This commit is contained in:
parent
6cc8ba5a5a
commit
9e5a42a23b
3 changed files with 18 additions and 1 deletions
|
@ -12,6 +12,8 @@
|
||||||
if {file:SASS_REFERENCE.md.html#property_syntax-option `:property_syntax`}
|
if {file:SASS_REFERENCE.md.html#property_syntax-option `:property_syntax`}
|
||||||
is set to `:new`.
|
is set to `:new`.
|
||||||
|
|
||||||
|
* Fixed `css2sass`'s generation of pseudo-classes so that they're backslash-escaped.
|
||||||
|
|
||||||
## [2.2.10](http://github.com/nex3/haml/commit/2.2.10)
|
## [2.2.10](http://github.com/nex3/haml/commit/2.2.10)
|
||||||
|
|
||||||
* Add support for attribute selectors with spaces around the `=`.
|
* Add support for attribute selectors with spaces around the `=`.
|
||||||
|
|
|
@ -24,7 +24,9 @@ module Sass
|
||||||
class RuleNode
|
class RuleNode
|
||||||
# @see Node#to_sass
|
# @see Node#to_sass
|
||||||
def to_sass(tabs, opts = {})
|
def to_sass(tabs, opts = {})
|
||||||
str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? PropNode } ? "\n" : ''}"
|
name = rules.first
|
||||||
|
name = "\\" + name if name[0] == ?:
|
||||||
|
str = "\n#{' ' * tabs}#{name}#{children.any? { |c| c.is_a? PropNode } ? "\n" : ''}"
|
||||||
|
|
||||||
children.each do |child|
|
children.each do |child|
|
||||||
str << "#{child.to_sass(tabs + 1, opts)}"
|
str << "#{child.to_sass(tabs + 1, opts)}"
|
||||||
|
|
|
@ -230,6 +230,19 @@ SASS
|
||||||
CSS
|
CSS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pseudo_classes_are_escaped
|
||||||
|
assert_equal(<<SASS, css2sass(<<CSS))
|
||||||
|
\\:focus
|
||||||
|
a: b
|
||||||
|
|
||||||
|
\\:foo
|
||||||
|
bar: baz
|
||||||
|
SASS
|
||||||
|
:focus {a: b;}
|
||||||
|
:focus :foo {bar: baz;}
|
||||||
|
CSS
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def css2sass(string, opts={})
|
def css2sass(string, opts={})
|
||||||
|
|
Loading…
Add table
Reference in a new issue