haml 2.0.5 → 2.0.6

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
- 2.0.5
1
+ 2.0.6
@@ -508,6 +508,22 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
508
508
  #
509
509
  # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
510
510
  #
511
+ # while
512
+ #
513
+ # !!! Basic
514
+ #
515
+ # is compiled to:
516
+ #
517
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
518
+ #
519
+ # and
520
+ #
521
+ # !!! Mobile
522
+ #
523
+ # is compiled to:
524
+ #
525
+ # <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
526
+ #
511
527
  # If you're not using the UTF-8 character set for your document,
512
528
  # you can specify which encoding should appear
513
529
  # in the XML prolog in a similar way.
@@ -235,6 +235,10 @@ END
235
235
  opts.on('-I', '--load-path PATH', "Same as 'ruby -I'.") do |path|
236
236
  @options[:load_paths] << path
237
237
  end
238
+
239
+ opts.on('--debug', "Print out the precompiled Ruby source.") do
240
+ @options[:debug] = true
241
+ end
238
242
  end
239
243
 
240
244
  def process_result
@@ -254,6 +258,12 @@ END
254
258
 
255
259
  @options[:load_paths].each {|p| $LOAD_PATH << p}
256
260
  @options[:requires].each {|f| require f}
261
+
262
+ if @options[:debug]
263
+ puts engine.precompiled
264
+ puts '=' * 100
265
+ end
266
+
257
267
  result = engine.to_html
258
268
  rescue Exception => e
259
269
  raise e if @options[:trace]
@@ -86,7 +86,7 @@ if defined?(ActionView) and not defined?(Merb::Plugins)
86
86
  else
87
87
  module CaptureHelper
88
88
  def capture_with_haml(*args, &block)
89
- if is_haml?
89
+ if is_haml? && block_is_haml?(block)
90
90
  capture_haml(*args, &block)
91
91
  else
92
92
  capture_without_haml(*args, &block)
@@ -695,6 +695,8 @@ END
695
695
  case type
696
696
  when "strict"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
697
697
  when "frameset"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'
698
+ when "mobile"; '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">'
699
+ when "basic"; '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">'
698
700
  else '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
699
701
  end
700
702
  end
@@ -270,8 +270,8 @@ HAML
270
270
  end
271
271
 
272
272
  def test_string_interpolation_should_be_esaped
273
- assert_equal("<p>4&amp;3</p>\n", render("%p== #{2+2}&#{2+1}", :escape_html => true))
274
- assert_equal("<p>4&3</p>\n", render("%p== #{2+2}&#{2+1}", :escape_html => false))
273
+ assert_equal("<p>4&amp;3</p>\n", render("%p== \#{2+2}&\#{2+1}", :escape_html => true))
274
+ assert_equal("<p>4&3</p>\n", render("%p== \#{2+2}&\#{2+1}", :escape_html => false))
275
275
  end
276
276
 
277
277
  def test_escaped_inline_string_interpolation
@@ -335,6 +335,31 @@ HAML
335
335
  assert_equal("", render(":ruby\n Kernel.puts 'hello'", :suppress_eval => true))
336
336
  end
337
337
 
338
+ def test_doctypes
339
+ assert_equal('<!DOCTYPE html>',
340
+ render('!!!', :format => :html5).strip)
341
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
342
+ render('!!! strict').strip)
343
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
344
+ render('!!! frameset').strip)
345
+ assert_equal('<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">',
346
+ render('!!! mobile').strip)
347
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
348
+ render('!!! basic').strip)
349
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
350
+ render('!!! transitional').strip)
351
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
352
+ render('!!!').strip)
353
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
354
+ render('!!! strict', :format => :html4).strip)
355
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
356
+ render('!!! frameset', :format => :html4).strip)
357
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
358
+ render('!!! transitional', :format => :html4).strip)
359
+ assert_equal('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
360
+ render('!!!', :format => :html4).strip)
361
+ end
362
+
338
363
  def test_attr_wrapper
339
364
  assert_equal("<p strange=*attrs*></p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*'))
340
365
  assert_equal("<p escaped='quo\"te'></p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
@@ -2,6 +2,12 @@
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
3
  require 'haml/template'
4
4
 
5
+ class ActionView::Base
6
+ def nested_tag
7
+ content_tag(:span) {content_tag(:div) {"something"}}
8
+ end
9
+ end
10
+
5
11
  class HelperTest < Test::Unit::TestCase
6
12
  include Haml::Helpers
7
13
  Post = Struct.new('Post', :body)
@@ -197,6 +203,10 @@ HAML
197
203
  def test_non_haml
198
204
  assert_equal("false\n", render("= non_haml { is_haml? }"))
199
205
  end
206
+
207
+ def test_content_tag_nested
208
+ assert_equal "<span><div>something</div></span>", render("= nested_tag", :action_view).strip
209
+ end
200
210
 
201
211
  class ActsLikeTag
202
212
  # We want to be able to have people include monkeypatched ActionView helpers
@@ -22,12 +22,10 @@ class Html2HamlTest < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  def test_should_have_pretty_attributes
25
- assert_equal_attributes('%input{ :type => "text", :name => "login" }/',
26
- render('<input type="text" name="login" />'))
27
- assert_equal_attributes('%meta{ "http-equiv" => "Content-Type", :content => "text/html" }/',
28
- render('<meta http-equiv="Content-Type" content="text/html" />'))
29
- assert_equal_attributes('%div{ "xml:lang" => "hr" }/',
30
- render('<div xml:lang="hr" />'))
25
+ assert_equal_attributes('%input{ :type => "text", :name => "login" }',
26
+ render('<input type="text" name="login" />'))
27
+ assert_equal_attributes('%meta{ "http-equiv" => "Content-Type", :content => "text/html" }',
28
+ render('<meta http-equiv="Content-Type" content="text/html" />'))
31
29
  end
32
30
 
33
31
  def test_sqml_comment
@@ -78,17 +76,17 @@ class Html2HamlTest < Test::Unit::TestCase
78
76
 
79
77
  protected
80
78
 
81
- def render(text, options = {})
82
- Haml::HTML.new(text, options).render.rstrip
83
- end
79
+ def render(text, options = {})
80
+ Haml::HTML.new(text, options).render.rstrip
81
+ end
84
82
 
85
- def render_rhtml(text)
86
- render(text, :rhtml => true)
87
- end
83
+ def render_rhtml(text)
84
+ render(text, :rhtml => true)
85
+ end
88
86
 
89
- def assert_equal_attributes(expected, result)
90
- expected_attr, result_attr = [expected, result].map { |s| s.gsub!(/\{ (.+) \}/, ''); $1.split(', ').sort }
91
- assert_equal expected_attr, result_attr
92
- assert_equal expected, result
93
- end
87
+ def assert_equal_attributes(expected, result)
88
+ expected_attr, result_attr = [expected, result].map { |s| s.gsub!(/\{ (.+) \}/, ''); $1.split(', ').sort }
89
+ assert_equal expected_attr, result_attr
90
+ assert_equal expected, result
91
+ end
94
92
  end
@@ -74,7 +74,11 @@ class TemplateTest < Test::Unit::TestCase
74
74
  end
75
75
 
76
76
  def assert_renders_correctly(name, &render_method)
77
- render_method ||= proc { |name| @base.render(:file => name) }
77
+ if ActionPack::VERSION::MAJOR < 2 || ActionPack::VERSION::MINOR < 2
78
+ render_method ||= proc { |name| @base.render(name) }
79
+ else
80
+ render_method ||= proc { |name| @base.render(:file => name) }
81
+ end
78
82
 
79
83
  load_result(name).split("\n").zip(render_method[name].split("\n")).each_with_index do |pair, line|
80
84
  message = "template: #{name}\nline: #{line}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-11-28 00:00:00 -08:00
13
+ date: 2008-12-17 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16