haml 3.0.17 → 3.0.18

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/README.md CHANGED
@@ -29,8 +29,9 @@ For more information on these commands, check out
29
29
  haml --help
30
30
  sass --help
31
31
 
32
- To install Haml and Sass as a Rails plugin,
33
- just run `haml --rails path/to/rails/app`
32
+ To install Haml and Sass in Rails 2,
33
+ just add `config.gem "haml"` to `config/environment.rb`.
34
+ In Rails 3, add `gem "haml"` to your Gemfile instead.
34
35
  and both Haml and Sass will be installed.
35
36
  Views with the `.html.haml` extension will automatically use Haml.
36
37
  Sass is a little more complicated;
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.17
1
+ 3.0.18
@@ -207,7 +207,7 @@ END
207
207
  "haml --rails will no longer work in the next version of #{@name}.", "")
208
208
  elsif File.exists?(env) && File.open(env) {|env| env.grep(/config\.gem/)}
209
209
  puts("haml --rails isn't needed for Rails 2.1 or greater.",
210
- "Add 'gem \"haml\"' to config/environment.rb instead.", "",
210
+ "Add 'config.gem \"haml\"' to config/environment.rb instead.", "",
211
211
  "haml --rails will no longer work in the next version of #{@name}.", "")
212
212
  end
213
213
 
@@ -294,6 +294,10 @@ END
294
294
  'Locations are set like --watch.') do
295
295
  @options[:update] = true
296
296
  end
297
+ opts.on('--stop-on-error', 'If a file fails to compile, exit immediately.',
298
+ 'Only meaningful for --watch and --update.') do
299
+ @options[:stop_on_error] = true
300
+ end
297
301
  opts.on('-t', '--style NAME',
298
302
  'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
299
303
  @options[:for_engine][:style] = name.to_sym
@@ -426,7 +430,7 @@ MSG
426
430
  ::Sass::Plugin.on_creating_directory {|dirname| puts_action :directory, :green, dirname}
427
431
  ::Sass::Plugin.on_deleting_css {|filename| puts_action :delete, :yellow, filename}
428
432
  ::Sass::Plugin.on_compilation_error do |error, _, _|
429
- raise error unless error.is_a?(::Sass::SyntaxError)
433
+ raise error unless error.is_a?(::Sass::SyntaxError) && !@options[:stop_on_error]
430
434
  had_error = true
431
435
  puts_action :error, :red, "#{error.sass_filename} (Line #{error.sass_line}: #{error.message})"
432
436
  end
@@ -442,7 +442,8 @@ MESSAGE
442
442
  text = rest.shift.to_s unless [Symbol, Hash, NilClass].any? {|t| rest.first.is_a? t}
443
443
  flags = []
444
444
  flags << rest.shift while rest.first.is_a? Symbol
445
- name, attrs = merge_name_and_attributes(name.to_s, rest.shift || {})
445
+ attrs = Haml::Util.map_keys(rest.shift || {}) {|key| key.to_s}
446
+ name, attrs = merge_name_and_attributes(name.to_s, attrs)
446
447
 
447
448
  attributes = Haml::Precompiler.build_attributes(haml_buffer.html?,
448
449
  haml_buffer.options[:attr_wrapper],
@@ -551,8 +552,7 @@ MESSAGE
551
552
  return name, attributes_hash unless name =~ /^(.+?)?([\.#].*)$/
552
553
 
553
554
  return $1 || "div", Buffer.merge_attrs(
554
- Precompiler.parse_class_and_id($2),
555
- Haml::Util.map_keys(attributes_hash) {|key| key.to_s})
555
+ Precompiler.parse_class_and_id($2), attributes_hash)
556
556
  end
557
557
 
558
558
  # Runs a block of code with the given buffer as the currently active buffer.
@@ -534,8 +534,8 @@ END
534
534
  result = attributes.collect do |attr, value|
535
535
  next if value.nil?
536
536
 
537
- value = filter_and_join(value, ' ') if attr == :class
538
- value = filter_and_join(value, '_') if attr == :id
537
+ value = filter_and_join(value, ' ') if attr == 'class'
538
+ value = filter_and_join(value, '_') if attr == 'id'
539
539
 
540
540
  if value == true
541
541
  next " #{attr}" if is_html
@@ -561,8 +561,10 @@ END
561
561
  end
562
562
 
563
563
  def self.filter_and_join(value, separator)
564
+ return "" if value == ""
564
565
  value = [value] unless value.is_a?(Array)
565
- return value.flatten.collect {|item| item ? item.to_s : nil}.compact.join(separator)
566
+ value = value.flatten.collect {|item| item ? item.to_s : nil}.compact.join(separator)
567
+ return !value.empty? && value
566
568
  end
567
569
 
568
570
  def prerender_tag(name, self_close, attributes)
@@ -231,6 +231,44 @@ module Haml
231
231
  info
232
232
  end
233
233
 
234
+ # Returns whether one version string represents a more recent version than another.
235
+ #
236
+ # @param v1 [String] A version string.
237
+ # @param v2 [String] Another version string.
238
+ # @return [Boolean]
239
+ def version_gt(v1, v2)
240
+ # Construct an array to make sure the shorter version is padded with nil
241
+ Array.new([v1.length, v2.length].max).zip(v1.split("."), v2.split(".")) do |_, p1, p2|
242
+ p1 ||= "0"
243
+ p2 ||= "0"
244
+ release1 = p1 =~ /^[0-9]+$/
245
+ release2 = p2 =~ /^[0-9]+$/
246
+ if release1 && release2
247
+ # Integer comparison if both are full releases
248
+ p1, p2 = p1.to_i, p2.to_i
249
+ next if p1 == p2
250
+ return p1 > p2
251
+ elsif !release1 && !release2
252
+ # String comparison if both are prereleases
253
+ next if p1 == p2
254
+ return p1 > p2
255
+ else
256
+ # If only one is a release, that one is newer
257
+ return release1
258
+ end
259
+ end
260
+ end
261
+
262
+ # Returns whether one version string represents the same or a more
263
+ # recent version than another.
264
+ #
265
+ # @param v1 [String] A version string.
266
+ # @param v2 [String] Another version string.
267
+ # @return [Boolean]
268
+ def version_geq(v1, v2)
269
+ version_gt(v1, v2) || !version_gt(v2, v1)
270
+ end
271
+
234
272
  # Silence all output to STDERR within a block.
235
273
  #
236
274
  # @yield A block in which no output will be printed to STDERR
@@ -269,8 +307,8 @@ module Haml
269
307
  #
270
308
  # @return [String, nil]
271
309
  def rails_root
272
- if defined?(Rails.root)
273
- return Rails.root.to_s if Rails.root
310
+ if defined?(::Rails.root)
311
+ return ::Rails.root.to_s if ::Rails.root
274
312
  raise "ERROR: Rails.root is nil!"
275
313
  end
276
314
  return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
@@ -283,7 +321,7 @@ module Haml
283
321
  #
284
322
  # @return [String, nil]
285
323
  def rails_env
286
- return Rails.env.to_s if defined?(Rails.root)
324
+ return ::Rails.env.to_s if defined?(::Rails.env)
287
325
  return RAILS_ENV.to_s if defined?(RAILS_ENV)
288
326
  return nil
289
327
  end
@@ -308,7 +346,7 @@ module Haml
308
346
  return false unless defined?(ActionPack) && defined?(ActionPack::VERSION) &&
309
347
  defined?(ActionPack::VERSION::STRING)
310
348
 
311
- ActionPack::VERSION::STRING >= version
349
+ version_geq(ActionPack::VERSION::STRING, version)
312
350
  end
313
351
 
314
352
  # Returns an ActionView::Template* class.
@@ -212,8 +212,18 @@ module Sass
212
212
  end
213
213
 
214
214
  def import_directive
215
- @expected = "string or url()"
216
- arg = tok(STRING) || (uri = tok!(URI))
215
+ values = []
216
+
217
+ loop do
218
+ values << expr!(:import_arg)
219
+ break if use_css_import? || !tok(/,\s*/)
220
+ end
221
+
222
+ return values
223
+ end
224
+
225
+ def import_arg
226
+ return unless arg = tok(STRING) || (uri = tok!(URI))
217
227
  path = @scanner[1] || @scanner[2] || @scanner[3]
218
228
  ss
219
229
 
@@ -318,7 +328,7 @@ module Sass
318
328
  def block_contents(node, context)
319
329
  block_given? ? yield : ss_comments(node)
320
330
  node << (child = block_child(context))
321
- while tok(/;/) || (child && child.has_children)
331
+ while tok(/;/) || has_children?(child)
322
332
  block_given? ? yield : ss_comments(node)
323
333
  node << (child = block_child(context))
324
334
  end
@@ -330,6 +340,12 @@ module Sass
330
340
  variable || directive || declaration_or_ruleset
331
341
  end
332
342
 
343
+ def has_children?(child_or_array)
344
+ return false unless child_or_array
345
+ return child_or_array.last.has_children if child_or_array.is_a?(Array)
346
+ return child_or_array.has_children
347
+ end
348
+
333
349
  # This is a nasty hack, and the only place in the parser
334
350
  # that requires backtracking.
335
351
  # The reason is that we can't figure out if certain strings
@@ -747,6 +763,7 @@ MESSAGE
747
763
  :expr => "expression (e.g. 1px, bold)",
748
764
  :selector_comma_sequence => "selector",
749
765
  :simple_selector_sequence => "selector",
766
+ :import_arg => "file to import (string or url())",
750
767
  }
751
768
 
752
769
  TOK_NAMES = Haml::Util.to_hash(
@@ -84,14 +84,18 @@ module Sass
84
84
 
85
85
  # Appends a child to the node.
86
86
  #
87
- # @param child [Tree::Node] The child node
87
+ # @param child [Tree::Node, Array<Tree::Node>] The child node or nodes
88
88
  # @raise [Sass::SyntaxError] if `child` is invalid
89
89
  # @see #invalid_child?
90
90
  def <<(child)
91
91
  return if child.nil?
92
- check_child! child
93
- self.has_children = true
94
- @children << child
92
+ if child.is_a?(Array)
93
+ child.each {|c| self << c}
94
+ else
95
+ check_child! child
96
+ self.has_children = true
97
+ @children << child
98
+ end
95
99
  end
96
100
 
97
101
  # Raises an error if the given child node is invalid.
@@ -148,7 +148,7 @@ MESSAGE
148
148
  assert_equal("<p class='b css'>foo</p>\n", render("%p.css{:class => %w[css b]} foo")) # merge uniquely
149
149
  assert_equal("<p class='a b c d'>foo</p>\n", render("%p{:class => [%w[a b], %w[c d]]} foo")) # flatten
150
150
  assert_equal("<p class='a b'>foo</p>\n", render("%p{:class => [:a, :b] } foo")) # stringify
151
- assert_equal("<p class=''>foo</p>\n", render("%p{:class => [nil, false] } foo")) # strip falsey
151
+ assert_equal("<p>foo</p>\n", render("%p{:class => [nil, false] } foo")) # strip falsey
152
152
  assert_equal("<p class='a'>foo</p>\n", render("%p{:class => :a} foo")) # single stringify
153
153
  assert_equal("<p>foo</p>\n", render("%p{:class => false} foo")) # single falsey
154
154
  assert_equal("<p class='a b html'>foo</p>\n", render("%p(class='html'){:class => %w[a b]} foo")) # html attrs
@@ -159,7 +159,7 @@ MESSAGE
159
159
  assert_equal("<p id='css_a_b'>foo</p>\n", render("%p#css{:id => %w[a b]} foo")) # merge with css
160
160
  assert_equal("<p id='a_b_c_d'>foo</p>\n", render("%p{:id => [%w[a b], %w[c d]]} foo")) # flatten
161
161
  assert_equal("<p id='a_b'>foo</p>\n", render("%p{:id => [:a, :b] } foo")) # stringify
162
- assert_equal("<p id=''>foo</p>\n", render("%p{:id => [nil, false] } foo")) # strip falsey
162
+ assert_equal("<p>foo</p>\n", render("%p{:id => [nil, false] } foo")) # strip falsey
163
163
  assert_equal("<p id='a'>foo</p>\n", render("%p{:id => :a} foo")) # single stringify
164
164
  assert_equal("<p>foo</p>\n", render("%p{:id => false} foo")) # single falsey
165
165
  assert_equal("<p id='html_a_b'>foo</p>\n", render("%p(id='html'){:id => %w[a b]} foo")) # html attrs
@@ -259,6 +259,11 @@ HAML
259
259
  assert_equal("<p id='c_a_b'>foo</p>\n", render("- haml_tag 'p#c', 'foo', :id => %w[a b]"))
260
260
  end
261
261
 
262
+ def test_haml_tag_with_data_hash
263
+ assert_equal("<p data-baz='data-baz' data-foo='bar'>foo</p>\n",
264
+ render("- haml_tag :p, 'foo', :data => {:foo => 'bar', :baz => true}"))
265
+ end
266
+
262
267
  def test_haml_tag_non_autoclosed_tags_arent_closed
263
268
  assert_equal("<p></p>\n", render("- haml_tag :p"))
264
269
  end
@@ -217,6 +217,29 @@ class UtilTest < Test::Unit::TestCase
217
217
  assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle {}'"))
218
218
  end
219
219
 
220
+ def test_version_gt
221
+ assert_version_gt("2.0.0", "1.0.0")
222
+ assert_version_gt("1.1.0", "1.0.0")
223
+ assert_version_gt("1.0.1", "1.0.0")
224
+ assert_version_gt("1.0.0", "1.0.0.rc")
225
+ assert_version_gt("1.0.0.1", "1.0.0.rc")
226
+ assert_version_gt("1.0.0.rc", "0.9.9")
227
+ assert_version_gt("1.0.0.beta", "1.0.0.alpha")
228
+
229
+ assert_version_eq("1.0.0", "1.0.0")
230
+ assert_version_eq("1.0.0", "1.0.0.0")
231
+ end
232
+
233
+ def assert_version_gt(v1, v2)
234
+ #assert(version_gt(v1, v2), "Expected #{v1} > #{v2}")
235
+ assert(!version_gt(v2, v1), "Expected #{v2} < #{v1}")
236
+ end
237
+
238
+ def assert_version_eq(v1, v2)
239
+ assert(!version_gt(v1, v2), "Expected #{v1} = #{v2}")
240
+ assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}")
241
+ end
242
+
220
243
  def test_def_static_method
221
244
  klass = Class.new
222
245
  def_static_method(klass, :static_method, [:arg1, :arg2],
@@ -12,4 +12,20 @@ body { font: Arial; background: blue; }
12
12
 
13
13
  midrule { inthe: middle; }
14
14
 
15
+ scss { imported: yes; }
16
+
17
+ body { font: Arial; background: blue; }
18
+
19
+ #page { width: 700px; height: 100; }
20
+ #page #header { height: 300px; }
21
+ #page #header h1 { font-size: 50px; color: blue; }
22
+
23
+ #content.user.show #container.top #column.left { width: 100px; }
24
+ #content.user.show #container.top #column.right { width: 600px; }
25
+ #content.user.show #container.bottom { background: brown; }
26
+
27
+ @import url(basic.css);
28
+ @import url(../results/complex.css);
29
+ #foo { background-color: #bbaaff; }
30
+
15
31
  nonimported { myconst: hello; otherconst: goodbye; post-mixin: here; }
@@ -2,7 +2,8 @@ $preconst: hello;
2
2
 
3
3
  @mixin premixin {pre-mixin: here}
4
4
 
5
- @import "importee.sass";
5
+ @import "importee.sass", "scss_importee", "basic.sass", "basic.css", "../results/complex.css";
6
+ @import "partial.sass";
6
7
 
7
8
  nonimported {
8
9
  myconst: $preconst;
@@ -76,7 +76,15 @@ class Test::Unit::TestCase
76
76
 
77
77
  def rails_form_opener
78
78
  return '' unless Haml::Util.ap_geq?("3.0.0.rc")
79
- return '<div style="margin:0;padding:0;display:inline"><input name="_snowman" type="hidden" value="&#9731;" /></div>'
79
+ if Haml::Util.ap_geq?("3.0.0.rc2")
80
+ encoding = 'utf8'
81
+ char = '&#x2713;'
82
+ else
83
+ encoding = '_snowman'
84
+ char = '&#9731;'
85
+ end
86
+ return '<div style="margin:0;padding:0;display:inline"><input name="' + encoding +
87
+ '" type="hidden" value="' + char + '" /></div>'
80
88
  end
81
89
 
82
90
  def assert_raise_message(klass, message)
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.17
4
+ hash: 35
5
+ prerelease: false
6
+ segments:
7
+ - 3
8
+ - 0
9
+ - 18
10
+ version: 3.0.18
5
11
  platform: ruby
6
12
  authors:
7
13
  - Nathan Weizenbaum
@@ -11,29 +17,41 @@ autorequire:
11
17
  bindir: bin
12
18
  cert_chain: []
13
19
 
14
- date: 2010-08-14 00:00:00 -07:00
20
+ date: 2010-08-29 00:00:00 -07:00
15
21
  default_executable:
16
22
  dependencies:
17
23
  - !ruby/object:Gem::Dependency
18
24
  name: yard
19
- type: :development
20
- version_requirement:
21
- version_requirements: !ruby/object:Gem::Requirement
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
22
28
  requirements:
23
29
  - - ">="
24
30
  - !ruby/object:Gem::Version
31
+ hash: 13
32
+ segments:
33
+ - 0
34
+ - 5
35
+ - 3
25
36
  version: 0.5.3
26
- version:
37
+ type: :development
38
+ version_requirements: *id001
27
39
  - !ruby/object:Gem::Dependency
28
40
  name: maruku
29
- type: :development
30
- version_requirement:
31
- version_requirements: !ruby/object:Gem::Requirement
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
32
44
  requirements:
33
45
  - - ">="
34
46
  - !ruby/object:Gem::Version
47
+ hash: 25
48
+ segments:
49
+ - 0
50
+ - 5
51
+ - 9
35
52
  version: 0.5.9
36
- version:
53
+ type: :development
54
+ version_requirements: *id002
37
55
  description: " Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML\n that's designed to express the structure of XHTML or XML documents\n in a non-repetitive, elegant, easy way,\n using indentation rather than closing tags\n and allowing Ruby to be embedded with ease.\n It was originally envisioned as a plugin for Ruby on Rails,\n but it can function as a stand-alone templating engine.\n"
38
56
  email: haml@googlegroups.com
39
57
  executables:
@@ -44,13 +62,8 @@ executables:
44
62
  - sass-convert
45
63
  extensions: []
46
64
 
47
- extra_rdoc_files:
48
- - VERSION
49
- - MIT-LICENSE
50
- - README.md
51
- - VERSION_NAME
52
- - REVISION
53
- - CONTRIBUTING
65
+ extra_rdoc_files: []
66
+
54
67
  files:
55
68
  - rails/init.rb
56
69
  - lib/sass.rb
@@ -339,33 +352,32 @@ homepage: http://haml-lang.com/
339
352
  licenses: []
340
353
 
341
354
  post_install_message:
342
- rdoc_options:
343
- - --title
344
- - Haml
345
- - --main
346
- - README.rdoc
347
- - --exclude
348
- - lib/haml/buffer.rb
349
- - --line-numbers
350
- - --inline-source
355
+ rdoc_options: []
356
+
351
357
  require_paths:
352
358
  - lib
353
359
  required_ruby_version: !ruby/object:Gem::Requirement
360
+ none: false
354
361
  requirements:
355
362
  - - ">="
356
363
  - !ruby/object:Gem::Version
364
+ hash: 3
365
+ segments:
366
+ - 0
357
367
  version: "0"
358
- version:
359
368
  required_rubygems_version: !ruby/object:Gem::Requirement
369
+ none: false
360
370
  requirements:
361
371
  - - ">="
362
372
  - !ruby/object:Gem::Version
373
+ hash: 3
374
+ segments:
375
+ - 0
363
376
  version: "0"
364
- version:
365
377
  requirements: []
366
378
 
367
379
  rubyforge_project: haml
368
- rubygems_version: 1.3.5
380
+ rubygems_version: 1.3.7
369
381
  signing_key:
370
382
  specification_version: 3
371
383
  summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.