haml 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.0
1
+ 1.7.1
@@ -60,18 +60,18 @@ module Haml
60
60
  if flattened
61
61
  result = Haml::Helpers.find_and_preserve(result)
62
62
  end
63
- unless result.nil?
64
- result = result.to_s
65
- while result[-1] == 10 # \n
66
- # String#chomp is slow
67
- result = result[0...-1]
68
- end
69
-
70
- result = result.gsub("\n", "\n#{tabs(tabulation)}")
71
- push_text result, tabulation
63
+
64
+ result = result.to_s
65
+ while result[-1] == 10 # \n
66
+ # String#chomp is slow
67
+ result = result[0...-1]
72
68
  end
69
+
70
+ result = result.gsub("\n", "\n#{tabs(tabulation)}")
71
+ push_text result, tabulation
73
72
  nil
74
73
  end
74
+
75
75
 
76
76
  def open_prerendered_tag(tag, tabulation)
77
77
  @buffer << "#{tabs(tabulation)}#{tag}"
@@ -100,7 +100,7 @@ module Haml
100
100
  TAG_REGEX = /[%]([-:\w]+)([-\w\.\#]*)(\{.*\})?(\[.*\])?([=\/\~]?)?(.*)?/
101
101
 
102
102
  # The Regex that matches a literal string or symbol value
103
- LITERAL_VALUE_REGEX = /^\s*(:(\w*)|(('|")([^\\\#]*?)\4))\s*$/
103
+ LITERAL_VALUE_REGEX = /^\s*(:(\w*)|(('|")([^\\\#'"]*?)\4))\s*$/
104
104
 
105
105
  FLAT_WARNING = <<END
106
106
  Haml deprecation warning:
@@ -123,7 +123,7 @@ END
123
123
  :suppress_eval => false,
124
124
  :attr_wrapper => "'",
125
125
  :locals => {},
126
- :autoclose => ['meta', 'img', 'link', 'script', 'br', 'hr'],
126
+ :autoclose => ['meta', 'img', 'link', 'br', 'hr'],
127
127
  :filters => {
128
128
  'sass' => Sass::Engine,
129
129
  'plain' => Haml::Filters::Plain,
@@ -334,7 +334,7 @@ END
334
334
  end
335
335
  when FILTER
336
336
  name = line[1..-1].downcase
337
- start_filtered(options[:filters][name] || name)
337
+ start_filtered(options[:filters][name.to_s] || name)
338
338
  when DOCTYPE
339
339
  if line[0...3] == '!!!'
340
340
  render_doctype(line)
@@ -709,7 +709,7 @@ END
709
709
  when '=', '~'
710
710
  parse = true
711
711
 
712
- if value.first == '='
712
+ if value[0] == ?=
713
713
  value = value[1..-1].strip.dump.gsub('\\#', '#')
714
714
  end
715
715
  end
@@ -313,7 +313,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
313
313
  # #main
314
314
  # :background-color = !main_color
315
315
  # p
316
- # :background-color = !bg_color + 32
316
+ # :background-color = !main_color + 32
317
317
  #
318
318
  # is compiled to:
319
319
  #
@@ -481,7 +481,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
481
481
  #
482
482
  # Sass allows you to choose between three different output styles
483
483
  # by setting the <tt>:style</tt> option.
484
- # In Rails, this is done by setting <tt>Sass::Template.options[:style]</tt>;
484
+ # In Rails, this is done by setting <tt>Sass::Plugin.options[:style]</tt>;
485
485
  # outside Rails, it's done by passing an options hash with </tt>:style</tt> set.
486
486
  #
487
487
  # === <tt>:nested</tt>
@@ -9,7 +9,7 @@ class Sass::Constant::Literal # :nodoc:
9
9
  # The regular expression matching numbers.
10
10
  NUMBER = /^(-?\d*?\.?)(\d+)([^\d\s]*)$/
11
11
 
12
- html_color_matcher = Sass::Constant::Color::HTML4_COLORS.keys.join '|'
12
+ html_color_matcher = Sass::Constant::Color::HTML4_COLORS.keys.map { |c| "^#{c}$" }.join '|'
13
13
 
14
14
  # The regular expression matching colors.
15
15
  COLOR = /^\# (?: [\da-f]{3} | [\da-f]{6} ) | #{html_color_matcher}/ix
@@ -210,7 +210,11 @@ module Sass
210
210
  end
211
211
 
212
212
  def has_children?(index, tabs)
213
- next_line = @lines[index]
213
+ next_line = ['//', 0]
214
+ while !next_line.nil? && next_line[0] == '//' && next_line[1] = 0
215
+ next_line = @lines[index]
216
+ index += 1
217
+ end
214
218
  next_line && next_line[1] > tabs
215
219
  end
216
220
 
@@ -58,6 +58,14 @@ class EngineTest < Test::Unit::TestCase
58
58
  assert_equal("<p>\n Hello World\n</p>\n", render("%p\n == Hello \#{who}", :locals => {:who => 'World'}))
59
59
  end
60
60
 
61
+ def test_nil_tag_value_should_render_as_empty
62
+ assert_equal("<p></p>\n", render("%p= nil"))
63
+ end
64
+
65
+ def test_tag_with_failed_if_should_render_as_empty
66
+ assert_equal("<p></p>\n", render("%p= 'Hello' if false"))
67
+ end
68
+
61
69
  # Options tests
62
70
 
63
71
  def test_stop_eval
@@ -106,6 +114,11 @@ class EngineTest < Test::Unit::TestCase
106
114
  assert_equal("NOT RECOMPILED\n", render(template, :locals => { :text => "first time" }))
107
115
  assert_equal("<p>first time</p>\n", render(template, :locals => { :text => "first time", :foo => 'bar' }))
108
116
  end
117
+
118
+ def test_dynamc_attrs_shouldnt_register_as_literal_values
119
+ assert_equal("<p a='b2c'>\n</p>\n", render('%p{:a => "b#{1 + 1}c"}'))
120
+ assert_equal("<p a='b2c'>\n</p>\n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}"))
121
+ end
109
122
 
110
123
  def test_comps
111
124
  assert_equal(-1, "foo" <=> nil)
@@ -44,7 +44,6 @@ testtest
44
44
  <br />
45
45
  <meta foo='bar' />
46
46
  <img />
47
- <script />
48
47
  <hr />
49
48
  <link />
50
49
  <script>Inline content</script>
@@ -56,7 +56,6 @@
56
56
  - when :foo
57
57
  %meta{ :foo => 'bar'}
58
58
  %img
59
- %script
60
59
  %hr
61
60
  %link
62
61
  %script Inline content
@@ -94,7 +94,11 @@ class SassEngineTest < Test::Unit::TestCase
94
94
  end
95
95
  end
96
96
  end
97
-
97
+
98
+ def test_empty_first_line
99
+ assert_equal("#a {\n b: c; }\n", Sass::Engine.new("#a\n\n b: c").render)
100
+ end
101
+
98
102
  private
99
103
 
100
104
  def renders_correctly(name, options={})
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: haml
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.7.0
7
- date: 2007-07-07 00:00:00 -07:00
6
+ version: 1.7.1
7
+ date: 2007-08-22 00:00:00 -07:00
8
8
  summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
9
9
  require_paths:
10
10
  - lib