GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Fork of nex3/haml
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/chriseppstein/haml.git
Broaden the alternate attribute syntax for Sass.


git-svn-id: svn://hamptoncatlin.com/haml/trunk@541 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Thu Jun 28 01:43:09 -0700 2007
commit  dc2cda98c355f9c211f3bf3f97e69bbe72939091
tree    702d1d654b70bce71633b36d57b57ec0c7303170
parent  4bf132877f113ce3e559af6d73c8ac3c46dcb123
...
39
40
41
42
43
 
 
 
44
45
46
 
47
48
49
 
 
 
50
51
52
...
217
218
219
220
 
 
221
222
223
 
 
 
 
 
 
224
225
226
227
228
229
230
231
 
 
232
233
234
...
242
243
244
245
 
246
247
248
...
39
40
41
 
 
42
43
44
45
46
 
47
48
 
 
49
50
51
52
53
54
...
219
220
221
 
222
223
224
 
 
225
226
227
228
229
230
231
 
 
 
 
 
 
 
232
233
234
235
236
...
244
245
246
 
247
248
249
250
0
@@ -39,14 +39,16 @@ module Sass
0
     # The character used to denote a compiler directive.
0
     DIRECTIVE_CHAR = ?@
0
 
0
- # The regex that matches attributes of the form <tt>:name attr</tt>.
0
- ATTRIBUTE = /:([^\s=:]+)\s*(=?)(?:\s+|$)(.*)/
0
+ # The regex that matches and extracts data from
0
+ # attributes of the form <tt>:name attr</tt>.
0
+ ATTRIBUTE = /^:([^\s=:]+)\s*(=?)(?:\s+|$)(.*)/
0
 
0
     # The regex that matches attributes of the form <tt>name: attr</tt>.
0
- ALTERNATE_ATTRIBUTE_SELECTOR = /^[^\s:]+:(\s+|$)/
0
+ ATTRIBUTE_ALTERNATE_MATCHER = /^[^\s:]+\s*[=:](\s|$)/
0
 
0
- # The regex that extracts data from attributes of the form <tt>name: attr</tt>.
0
- ATTRIBUTE_ALTERNATE = /([^\s=]+):\s*(=?)\s*(.*)/
0
+ # The regex that matches and extracts data from
0
+ # attributes of the form <tt>name: attr</tt>.
0
+ ATTRIBUTE_ALTERNATE = /^([^\s=:]+)(\s*=|:)(?:\s+|$)(.*)/
0
 
0
     # Creates a new instace of Sass::Engine that will compile the given
0
     # template string when <tt>render</tt> is called.
0
@@ -217,18 +219,18 @@ module Sass
0
     end
0
 
0
     def parse_line(line)
0
- if line[0] == ATTRIBUTE_CHAR
0
+ case line[0]
0
+ when ATTRIBUTE_CHAR
0
         parse_attribute(line, ATTRIBUTE)
0
- elsif line.match(ALTERNATE_ATTRIBUTE_SELECTOR)
0
- parse_attribute(line, ATTRIBUTE_ALTERNATE)
0
+ when Constant::CONSTANT_CHAR
0
+ parse_constant(line)
0
+ when COMMENT_CHAR
0
+ parse_comment(line)
0
+ when DIRECTIVE_CHAR
0
+ parse_directive(line)
0
       else
0
- case line[0]
0
- when Constant::CONSTANT_CHAR
0
- parse_constant(line)
0
- when COMMENT_CHAR
0
- parse_comment(line)
0
- when DIRECTIVE_CHAR
0
- parse_directive(line)
0
+ if line =~ ATTRIBUTE_ALTERNATE_MATCHER
0
+ parse_attribute(line, ATTRIBUTE_ALTERNATE)
0
         else
0
           Tree::RuleNode.new(line, @options[:style])
0
         end
0
@@ -242,7 +244,7 @@ module Sass
0
         raise SyntaxError.new("Invalid attribute: \"#{line}\"", @line)
0
       end
0
 
0
- if eq[0] == SCRIPT_CHAR
0
+ if eq.strip[0] == SCRIPT_CHAR
0
         value = Sass::Constant.parse(value, @constants, @line).to_s
0
       end
0
 
...
22
23
24
 
 
25
 
 
26
27
28
...
61
62
63
64
 
65
66
67
...
22
23
24
25
26
27
28
29
30
31
32
...
65
66
67
 
68
69
70
71
0
@@ -22,7 +22,11 @@ class SassEngineTest < Test::Unit::TestCase
0
     ":= a" => 'Invalid attribute: ":= a"',
0
     "a\n :b" => 'Invalid attribute: ":b "',
0
     "a\n :b: c" => 'Invalid attribute: ":b: c"',
0
+ "a\n :b:c d" => 'Invalid attribute: ":b:c d"',
0
+ "a\n :b=c d" => 'Invalid attribute: ":b=c d"',
0
     "a\n :b c;" => 'Invalid attribute: ":b c;" (This isn\'t CSS!)',
0
+ "a\n b : c" => 'Invalid attribute: "b : c"',
0
+ "a\n b=c: d" => 'Invalid attribute: "b=c: d"',
0
     ":a" => 'Attributes aren\'t allowed at the root of a document.',
0
     "!" => 'Invalid constant: "!"',
0
     "!a" => 'Invalid constant: "!a"',
0
@@ -61,7 +65,7 @@ class SassEngineTest < Test::Unit::TestCase
0
         assert(err.sass_line, "Line: #{key}")
0
         assert_match(/\(sass\):[0-9]+/, err.backtrace[0], "Line: #{key}")
0
       else
0
- assert(false, "Exception not raised for '#{key}'!")
0
+ assert(false, "Exception not raised for\n#{key}")
0
       end
0
     end
0
   end
...
26
27
28
29
 
30
31
32
...
26
27
28
 
29
30
31
32
0
@@ -26,7 +26,7 @@ class SassPluginTest < Test::Unit::TestCase
0
   end
0
   
0
   def teardown
0
- FileUtils.rm_r File.dirname(__FILE__) + '/tmp'
0
+ FileUtils.rm_r File.dirname(__FILE__) + '/tmp'
0
   end
0
 
0
   def test_templates_should_render_correctly
...
1
2
3
 
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
 h1 { float: left; width: 274px; height: 75px; margin: 0; background-repeat: no-repeat; background-image: none; }
0
 h1 a:hover, h1 a:visited { color: green; }
0
 h1 b:hover { color: red; background-color: green; }
0
+h1 const { nosp: 3; sp: 3; }
...
11
12
13
 
 
 
...
11
12
13
14
15
16
0
@@ -11,3 +11,6 @@ h1
0
   b:hover
0
     color: red
0
     :background-color green
0
+ const
0
+ nosp= 1 + 2
0
+ sp = 1 + 2

Comments

    No one has commented yet.