radiant 0.6.7 → 0.6.8

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

Potentially problematic release.


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

Files changed (96) hide show
  1. data/CHANGELOG +35 -3
  2. data/CONTRIBUTORS +11 -1
  3. data/README +5 -3
  4. data/app/controllers/admin/welcome_controller.rb +7 -0
  5. data/app/migrate/020_add_session_info_to_users.rb +11 -0
  6. data/app/models/page.rb +22 -9
  7. data/app/models/standard_tags.rb +133 -10
  8. data/app/models/user.rb +9 -1
  9. data/app/views/admin/page/edit.html.haml +5 -4
  10. data/app/views/admin/welcome/login.html.haml +42 -24
  11. data/app/views/layouts/application.html.haml +1 -1
  12. data/config/environment.rb +4 -2
  13. data/db/migrate/020_add_session_info_to_users.rb +11 -0
  14. data/db/migrate/021_remove_session_expire_from_users.rb +9 -0
  15. data/db/schema.rb +3 -2
  16. data/lib/generators/instance/instance_generator.rb +2 -1
  17. data/lib/generators/instance/templates/instance_environment.rb +5 -3
  18. data/lib/login_system.rb +13 -0
  19. data/lib/radiant.rb +1 -1
  20. data/lib/radiant/admin_ui.rb +21 -21
  21. data/lib/radiant/extension/script.rb +251 -0
  22. data/lib/radiant/extension_loader.rb +22 -20
  23. data/lib/radiant/initializer.rb +1 -1
  24. data/lib/radiant/setup.rb +2 -0
  25. data/lib/tasks/framework.rake +39 -29
  26. data/public/500.html +1 -1
  27. data/public/javascripts/admin/admin.js +11 -9
  28. data/script/extension +5 -0
  29. data/spec/controllers/admin/user_controller_spec.rb +1 -1
  30. data/spec/controllers/admin/welcome_controller_spec.rb +31 -5
  31. data/spec/controllers/site_controller_spec.rb +15 -2
  32. data/spec/lib/login_system_spec.rb +106 -60
  33. data/spec/lib/radiant/extension/script_spec.rb +349 -0
  34. data/spec/lib/radiant/extension_loader_spec.rb +3 -0
  35. data/spec/models/page_spec.rb +62 -2
  36. data/spec/models/standard_tags_spec.rb +150 -3
  37. data/spec/models/user_spec.rb +28 -0
  38. data/spec/scenarios/file_not_found_scenario.rb +5 -0
  39. data/spec/scenarios/pages_scenario.rb +6 -0
  40. data/spec/scenarios/snippets_scenario.rb +4 -0
  41. data/test/fixtures/users.yml +11 -6
  42. data/vendor/plugins/haml/FAQ +138 -0
  43. data/vendor/plugins/haml/REVISION +1 -0
  44. data/vendor/plugins/haml/Rakefile +54 -62
  45. data/vendor/plugins/haml/VERSION +1 -1
  46. data/vendor/plugins/haml/init.rb +6 -1
  47. data/vendor/plugins/haml/lib/haml.rb +72 -12
  48. data/vendor/plugins/haml/lib/haml/buffer.rb +47 -40
  49. data/vendor/plugins/haml/lib/haml/engine.rb +20 -30
  50. data/vendor/plugins/haml/lib/haml/error.rb +4 -5
  51. data/vendor/plugins/haml/lib/haml/exec.rb +4 -2
  52. data/vendor/plugins/haml/lib/haml/filters.rb +30 -15
  53. data/vendor/plugins/haml/lib/haml/helpers.rb +47 -28
  54. data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +74 -25
  55. data/vendor/plugins/haml/lib/haml/precompiler.rb +92 -51
  56. data/vendor/plugins/haml/lib/haml/template.rb +11 -3
  57. data/vendor/plugins/haml/lib/haml/template/patch.rb +1 -1
  58. data/vendor/plugins/haml/lib/sass.rb +26 -3
  59. data/vendor/plugins/haml/lib/sass/constant.rb +26 -57
  60. data/vendor/plugins/haml/lib/sass/constant/literal.rb +1 -0
  61. data/vendor/plugins/haml/lib/sass/constant/nil.rb +9 -0
  62. data/vendor/plugins/haml/lib/sass/css.rb +17 -2
  63. data/vendor/plugins/haml/lib/sass/engine.rb +11 -5
  64. data/vendor/plugins/haml/test/haml/engine_test.rb +57 -39
  65. data/vendor/plugins/haml/test/haml/helper_test.rb +20 -4
  66. data/vendor/plugins/haml/test/haml/html2haml_test.rb +1 -3
  67. data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +1 -2
  68. data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +2 -4
  69. data/vendor/plugins/haml/test/haml/results/filters.xhtml +12 -8
  70. data/vendor/plugins/haml/test/haml/results/helpers.xhtml +2 -5
  71. data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +1 -3
  72. data/vendor/plugins/haml/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  73. data/vendor/plugins/haml/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  74. data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +2 -4
  75. data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +1 -6
  76. data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +2 -4
  77. data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +13 -21
  78. data/vendor/plugins/haml/test/haml/template_test.rb +31 -48
  79. data/vendor/plugins/haml/test/haml/templates/filters.haml +13 -0
  80. data/vendor/plugins/haml/test/haml/templates/helpers.haml +1 -1
  81. data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +0 -1
  82. data/vendor/plugins/haml/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  83. data/vendor/plugins/haml/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  84. data/vendor/plugins/haml/test/haml/templates/partials.haml +1 -1
  85. data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +0 -3
  86. data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +10 -10
  87. data/vendor/plugins/haml/test/sass/engine_test.rb +11 -5
  88. data/vendor/plugins/haml/test/sass/plugin_test.rb +2 -6
  89. data/vendor/plugins/haml/test/sass/results/constants.css +2 -0
  90. data/vendor/plugins/haml/test/sass/templates/constants.sass +3 -0
  91. data/vendor/plugins/haml/test/{haml/test_helper.rb → test_helper.rb} +4 -3
  92. metadata +21 -11
  93. data/vendor/plugins/haml/TODO +0 -9
  94. data/vendor/plugins/haml/extra/haml-mode.el +0 -328
  95. data/vendor/plugins/haml/extra/sass-mode.el +0 -88
  96. data/vendor/plugins/haml/test/profile.rb +0 -65
@@ -4,6 +4,7 @@ module Sass::Constant; class Literal; end; end; # :nodoc:
4
4
  require 'sass/constant/string'
5
5
  require 'sass/constant/number'
6
6
  require 'sass/constant/color'
7
+ require 'sass/constant/nil'
7
8
 
8
9
  class Sass::Constant::Literal # :nodoc:
9
10
  # The regular expression matching numbers.
@@ -0,0 +1,9 @@
1
+ require 'sass/constant/literal'
2
+
3
+ module Sass::Constant # :nodoc:
4
+ class Nil < Literal # :nodoc:
5
+ def to_s
6
+ ''
7
+ end
8
+ end
9
+ end
@@ -46,25 +46,40 @@ module Sass
46
46
  # It keeps the semantics and most of the efficiency of normal hashes
47
47
  # while also keeping track of the order in which elements were set.
48
48
  class OrderedHash
49
- Node = Struct.new('Node', :key, :value, :next)
49
+ Node = Struct.new(:key, :value, :next, :prev)
50
50
  include Enumerable
51
51
 
52
52
  def initialize
53
53
  @hash = {}
54
54
  end
55
55
 
56
+ def initialize_copy(other)
57
+ @hash = other.instance_variable_get('@hash').clone
58
+ end
59
+
56
60
  def [](key)
57
61
  @hash[key] && @hash[key].value
58
62
  end
59
63
 
60
64
  def []=(key, value)
61
- node = Node.new(key, value, nil)
65
+ node = Node.new(key, value)
66
+
67
+ if old = @hash[key]
68
+ if old.prev
69
+ old.prev.next = old.next
70
+ else # old is @first and @last
71
+ @first = @last = nil
72
+ end
73
+ end
74
+
62
75
  if @first.nil?
63
76
  @first = @last = node
64
77
  else
78
+ node.prev = @last
65
79
  @last.next = node
66
80
  @last = node
67
81
  end
82
+
68
83
  @hash[key] = node
69
84
  value
70
85
  end
@@ -76,7 +76,7 @@ module Sass
76
76
  :style => :nested,
77
77
  :load_paths => ['.']
78
78
  }.merge! options
79
- @template = template.split(/\n?\r|\r?\n/)
79
+ @template = template.split(/\r\n|\r|\n/)
80
80
  @lines = []
81
81
  @constants = {"important" => "!important"}
82
82
  @mixins = {}
@@ -134,7 +134,7 @@ module Sass
134
134
  # and computes the tabulation of the line.
135
135
  def split_lines
136
136
  @line = 0
137
- old_tabs = 0
137
+ old_tabs = nil
138
138
  @template.each_with_index do |line, index|
139
139
  @line += 1
140
140
 
@@ -145,14 +145,16 @@ module Sass
145
145
  end
146
146
 
147
147
  if tabs # if line isn't blank
148
- if tabs - old_tabs > 1
148
+ raise SyntaxError.new("Indenting at the beginning of the document is illegal.", @line) if old_tabs.nil? && tabs > 0
149
+
150
+ if old_tabs && tabs - old_tabs > 1
149
151
  raise SyntaxError.new("#{tabs * 2} spaces were used for indentation. Sass must be indented using two spaces.", @line)
150
152
  end
151
153
  @lines << [line.strip, tabs]
152
154
 
153
155
  old_tabs = tabs
154
156
  else
155
- @lines << ['//', old_tabs]
157
+ @lines << ['//', old_tabs || 0]
156
158
  end
157
159
  end
158
160
 
@@ -287,7 +289,11 @@ END
287
289
  when MIXIN_DEFINITION_CHAR
288
290
  parse_mixin_definition(line)
289
291
  when MIXIN_INCLUDE_CHAR
290
- parse_mixin_include(line)
292
+ if line[1].nil? || line[1] == ?\s
293
+ Tree::RuleNode.new(line, @options[:style])
294
+ else
295
+ parse_mixin_include(line)
296
+ end
291
297
  else
292
298
  if line =~ ATTRIBUTE_ALTERNATE_MATCHER
293
299
  parse_attribute(line, ATTRIBUTE_ALTERNATE)
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/test_helper'
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
3
 
4
4
  class EngineTest < Test::Unit::TestCase
5
5
  # A map of erroneous Sass documents to the error messages they should produce.
@@ -32,11 +32,23 @@ END
32
32
  ".= a" => "Illegal element: classes and ids must have values.",
33
33
  "%p..a" => "Illegal element: classes and ids must have values.",
34
34
  "%a/ b" => "Self-closing tags can't have content.",
35
+ " %p foo" => "Indenting at the beginning of the document is illegal.",
36
+ " %p foo" => "Indenting at the beginning of the document is illegal.",
37
+ " \n\t\n %p foo" => ["Indenting at the beginning of the document is illegal.", 3],
35
38
 
36
39
  # Regression tests
37
40
  "- raise 'foo'\n\n\n\nbar" => ["foo", 1],
38
41
  "= 'foo'\n-raise 'foo'" => ["foo", 2],
39
42
  "\n\n\n- raise 'foo'" => ["foo", 4],
43
+ "foo\n\n\n bar" => ["Illegal nesting: nesting within plain text is illegal.", 4],
44
+ "%p/\n\n bar" => ["Illegal nesting: nesting within a self-closing tag is illegal.", 3],
45
+ "%p foo\n\n bar" => ["Illegal nesting: content can't be both given on the same line as %p and nested within it.", 3],
46
+ "/ foo\n\n bar" => ["Illegal nesting: nesting within a tag that already has content is illegal.", 3],
47
+ "!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
48
+ "foo\n\n\n\tbar" => [<<END.strip, 4],
49
+ A tab character was used for indentation. Haml must be indented using two spaces.
50
+ Are you sure you have soft tabs enabled in your editor?
51
+ END
40
52
  }
41
53
 
42
54
  User = Struct.new('User', :id)
@@ -52,7 +64,7 @@ END
52
64
  end
53
65
 
54
66
  def test_attributes_should_render_correctly
55
- assert_equal("<div class='atlantis' style='ugly'>\n</div>", render(".atlantis{:style => 'ugly'}").chomp)
67
+ assert_equal("<div class='atlantis' style='ugly'></div>", render(".atlantis{:style => 'ugly'}").chomp)
56
68
  end
57
69
 
58
70
  def test_ruby_code_should_work_inside_attributes
@@ -61,7 +73,7 @@ END
61
73
  end
62
74
 
63
75
  def test_nil_should_render_empty_tag
64
- assert_equal("<div class='no_attributes'>\n</div>",
76
+ assert_equal("<div class='no_attributes'></div>",
65
77
  render(".no_attributes{:nil => nil}").chomp)
66
78
  end
67
79
 
@@ -128,20 +140,38 @@ END
128
140
 
129
141
  assert_equal("<textarea>#{'a' * 100}</textarea>\n",
130
142
  render("%textarea #{'a' * 100}"))
143
+
144
+ assert_equal("<p>\n <textarea>Foo\n Bar\n Baz</textarea>\n</p>\n", render(<<SOURCE))
145
+ %p
146
+ %textarea
147
+ Foo
148
+ Bar
149
+ Baz
150
+ SOURCE
131
151
  end
132
152
 
133
153
  def test_boolean_attributes
134
- assert_equal("<p bar baz='true' foo='bar'>\n</p>\n",
154
+ assert_equal("<p bar baz='true' foo='bar'></p>\n",
135
155
  render("%p{:foo => 'bar', :bar => true, :baz => 'true'}", :format => :html4))
136
- assert_equal("<p bar='bar' baz='true' foo='bar'>\n</p>\n",
156
+ assert_equal("<p bar='bar' baz='true' foo='bar'></p>\n",
137
157
  render("%p{:foo => 'bar', :bar => true, :baz => 'true'}", :format => :xhtml))
138
158
 
139
- assert_equal("<p baz='false' foo='bar'>\n</p>\n",
159
+ assert_equal("<p baz='false' foo='bar'></p>\n",
140
160
  render("%p{:foo => 'bar', :bar => false, :baz => 'false'}", :format => :html4))
141
- assert_equal("<p baz='false' foo='bar'>\n</p>\n",
161
+ assert_equal("<p baz='false' foo='bar'></p>\n",
142
162
  render("%p{:foo => 'bar', :bar => false, :baz => 'false'}", :format => :xhtml))
143
163
  end
144
164
 
165
+ def test_both_whitespace_nukes_work_together
166
+ assert_equal(<<RESULT, render(<<SOURCE))
167
+ <p><q>Foo
168
+ Bar</q></p>
169
+ RESULT
170
+ %p
171
+ %q><= "Foo\\nBar"
172
+ SOURCE
173
+ end
174
+
145
175
  # HTML escaping tests
146
176
 
147
177
  def test_ampersand_equals_should_escape
@@ -241,29 +271,22 @@ END
241
271
  assert_equal("<div id='foo' yes='no' />\n", render("#foo{:yes => 'no'}/", :suppress_eval => true))
242
272
  assert_equal("<div id='foo' />\n", render("#foo{:yes => 'no', :call => a_function() }/", :suppress_eval => true))
243
273
  assert_equal("<div />\n", render("%div[1]/", :suppress_eval => true))
244
-
245
- begin
246
- assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))
247
- rescue Haml::Error => err
248
- caught = true
249
- assert_equal('Filter "ruby" is not defined.', err.message)
250
- end
251
- assert(caught, "Rendering a ruby filter without evaluating didn't throw an error!")
274
+ assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))
252
275
  end
253
276
 
254
277
  def test_attr_wrapper
255
- assert_equal("<p strange=*attrs*>\n</p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*'))
256
- assert_equal("<p escaped='quo\"te'>\n</p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
257
- assert_equal("<p escaped=\"quo'te\">\n</p>\n", render("%p{ :escaped => 'quo\\'te'}", :attr_wrapper => '"'))
258
- assert_equal("<p escaped=\"q'uo&quot;te\">\n</p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"'))
278
+ assert_equal("<p strange=*attrs*></p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*'))
279
+ assert_equal("<p escaped='quo\"te'></p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
280
+ assert_equal("<p escaped=\"quo'te\"></p>\n", render("%p{ :escaped => 'quo\\'te'}", :attr_wrapper => '"'))
281
+ assert_equal("<p escaped=\"q'uo&quot;te\"></p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"'))
259
282
  assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n", render("!!! XML", :attr_wrapper => '"'))
260
283
  end
261
284
 
262
285
  def test_attrs_parsed_correctly
263
- assert_equal("<p boom=>biddly='bar =&gt; baz'>\n</p>\n", render("%p{'boom=>biddly' => 'bar => baz'}"))
264
- assert_equal("<p foo,bar='baz, qux'>\n</p>\n", render("%p{'foo,bar' => 'baz, qux'}"))
265
- assert_equal("<p escaped='quo\nte'>\n</p>\n", render("%p{ :escaped => \"quo\\nte\"}"))
266
- assert_equal("<p escaped='quo4te'>\n</p>\n", render("%p{ :escaped => \"quo\#{2 + 2}te\"}"))
286
+ assert_equal("<p boom=>biddly='bar =&gt; baz'></p>\n", render("%p{'boom=>biddly' => 'bar => baz'}"))
287
+ assert_equal("<p foo,bar='baz, qux'></p>\n", render("%p{'foo,bar' => 'baz, qux'}"))
288
+ assert_equal("<p escaped='quo\nte'></p>\n", render("%p{ :escaped => \"quo\\nte\"}"))
289
+ assert_equal("<p escaped='quo4te'></p>\n", render("%p{ :escaped => \"quo\#{2 + 2}te\"}"))
267
290
  end
268
291
 
269
292
  def test_correct_parsing_with_brackets
@@ -313,21 +336,9 @@ END
313
336
  assert_equal("<p>Paragraph!</p>\n", render("%p= text", :locals => { :text => "Paragraph!" }))
314
337
  end
315
338
 
316
- def test_deprecated_locals_option
317
- Kernel.module_eval do
318
- def warn_with_stub(msg); end
319
- alias_method :warn_without_stub, :warn
320
- alias_method :warn, :warn_with_stub
321
- end
322
-
323
- assert_equal("<p>Paragraph!</p>\n", Haml::Engine.new("%p= text", :locals => { :text => "Paragraph!" }).render)
324
-
325
- Kernel.module_eval { alias_method :warn, :warn_without_stub }
326
- end
327
-
328
339
  def test_dynamic_attrs_shouldnt_register_as_literal_values
329
- assert_equal("<p a='b2c'>\n</p>\n", render('%p{:a => "b#{1 + 1}c"}'))
330
- assert_equal("<p a='b2c'>\n</p>\n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}"))
340
+ assert_equal("<p a='b2c'></p>\n", render('%p{:a => "b#{1 + 1}c"}'))
341
+ assert_equal("<p a='b2c'></p>\n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}"))
331
342
  end
332
343
 
333
344
  def test_dynamic_attrs_with_self_closed_tag
@@ -542,6 +553,13 @@ END
542
553
  render("%p= 's' * 75", :ugly => true))
543
554
  end
544
555
 
556
+ def test_auto_preserve_unless_ugly
557
+ assert_equal("<pre>foo&#x000A;bar</pre>\n", render('%pre="foo\nbar"'))
558
+ assert_equal("<pre>foo\nbar</pre>\n", render("%pre\n foo\n bar"))
559
+ assert_equal("<pre>foo\nbar</pre>\n", render('%pre="foo\nbar"', :ugly => true))
560
+ assert_equal("<pre>foo\nbar</pre>\n", render("%pre\n foo\n bar", :ugly => true))
561
+ end
562
+
545
563
  def test_xhtml_output_option
546
564
  assert_equal "<p>\n <br />\n</p>\n", render("%p\n %br", :format => :xhtml)
547
565
  assert_equal "<a />\n", render("%a/", :format => :xhtml)
@@ -559,11 +577,11 @@ END
559
577
  end
560
578
 
561
579
  def test_html_renders_empty_node_with_closing_tag
562
- assert_equal %{<div class='foo'>\n</div>\n}, render(".foo", :format => :html4)
580
+ assert_equal "<div class='foo'></div>\n", render(".foo", :format => :html4)
563
581
  end
564
582
 
565
583
  def test_html_ignores_explicit_self_closing_declaration
566
- assert_equal "<a>\n</a>\n", render("%a/", :format => :html4)
584
+ assert_equal "<a></a>\n", render("%a/", :format => :html4)
567
585
  end
568
586
 
569
587
  def test_html_ignores_xml_prolog_declaration
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/test_helper'
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
3
  require 'haml/template'
4
4
 
5
5
  class HelperTest < Test::Unit::TestCase
@@ -105,7 +105,23 @@ class HelperTest < Test::Unit::TestCase
105
105
  end
106
106
 
107
107
  def test_haml_tag_non_autoclosed_tags_arent_closed
108
- assert_equal("<p>\n</p>\n", render("- haml_tag :p"))
108
+ assert_equal("<p></p>\n", render("- haml_tag :p"))
109
+ end
110
+
111
+ def test_haml_tag_renders_text_on_a_single_line
112
+ assert_equal("<p>#{'a' * 100}</p>\n", render("- haml_tag :p, 'a' * 100"))
113
+ end
114
+
115
+ def test_haml_tag_raises_error_for_multiple_content
116
+ assert_raise(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") }
117
+ end
118
+
119
+ def test_haml_tag_flags
120
+ assert_equal("<p />\n", render("- haml_tag :p, :/"))
121
+ assert_equal("<p>kumquat</p>\n", render("- haml_tag :p, :< do\n kumquat"))
122
+
123
+ assert_raise(Haml::Error) { render("- haml_tag :p, 'foo', :/") }
124
+ assert_raise(Haml::Error) { render("- haml_tag :p, :/ do\n foo") }
109
125
  end
110
126
 
111
127
  def test_is_haml
@@ -141,12 +157,12 @@ class HelperTest < Test::Unit::TestCase
141
157
  end
142
158
 
143
159
  def test_find_and_preserve_with_block
144
- assert_equal("<pre>&#x000A; Foo&#x000A; Bar&#x000A;</pre>\nFoo\nBar\n",
160
+ assert_equal("<pre>Foo&#x000A;Bar</pre>\nFoo\nBar\n",
145
161
  render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
146
162
  end
147
163
 
148
164
  def test_preserve_with_block
149
- assert_equal("<pre>&#x000A; Foo&#x000A; Bar&#x000A;</pre>&#x000A;Foo&#x000A;Bar&#x000A;\n",
165
+ assert_equal("<pre>Foo&#x000A;Bar</pre>&#x000A;Foo&#x000A;Bar\n",
150
166
  render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
151
167
  end
152
168
 
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require File.dirname(__FILE__) + '/../../lib/haml'
2
+ require File.dirname(__FILE__) + '/../test_helper'
5
3
  require 'haml/html'
6
4
 
7
5
  class Html2HamlTest < Test::Unit::TestCase
@@ -1,7 +1,6 @@
1
1
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
2
  <html>
3
- <head>
4
- </head>
3
+ <head></head>
5
4
  <body>
6
5
  <div id='content'>
7
6
  Lorem ipsum dolor sit amet
@@ -1,7 +1,5 @@
1
- <p>
2
- </p>
3
- <p>
4
- </p>
1
+ <p></p>
2
+ <p></p>
5
3
  <h1>Me!</h1>
6
4
  <div id='foo'>
7
5
  <p id='bar'>All</p>
@@ -11,9 +11,7 @@ TESTING HAHAHAHA!
11
11
  <h1>Foo</h1>
12
12
 
13
13
 
14
- <pre><code>This is preformatted!
15
- Look at that!
16
- Wowie-zowie!</code></pre>
14
+ <pre><code>This is preformatted!&#x000A;Look at that!&#x000A;Wowie-zowie!</code></pre>
17
15
 
18
16
 
19
17
  <p><strong>boldilicious!</strong></p>
@@ -40,10 +38,8 @@ This
40
38
  \#{also not}
41
39
  \\
42
40
  <p>
43
- <pre>
44
- This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work?&#x000A;
45
- This one is, too.&#x000A;Nested, that is.&#x000A;&#x000A;
46
- </pre>
41
+ <pre>This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work?
42
+ This one is, too.&#x000A;Nested, that is.&#x000A;</pre>
47
43
  </p>
48
44
  <ul>
49
45
 
@@ -71,6 +67,12 @@ This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work
71
67
 
72
68
  </ul>
73
69
  <div class='res'>178</div>
70
+ <p>
71
+ <p>I like preserved text:</p>
72
+
73
+
74
+ <pre><code>Foo&#x000A; Bar!&#x000A;Baz</code></pre>
75
+ </p>
74
76
  <ul>
75
77
  <li>Foo</li>
76
78
  <li>Bar</li>
@@ -79,4 +81,6 @@ This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work
79
81
  Text!
80
82
  Hello, World!
81
83
  How are you doing today?
82
-
84
+ &lt;div class=&quot;foo&quot;&gt;
85
+ &lt;p&gt;I think &amp;mdash; or do I?&lt;/p&gt;
86
+ &lt;/div&gt;
@@ -79,9 +79,7 @@ foo
79
79
  <table>
80
80
  <tr>
81
81
  <td class='cell'>
82
- <strong>
83
- strong!
84
- </strong>
82
+ <strong>strong!</strong>
85
83
  data
86
84
  </td>
87
85
  <td>
@@ -90,5 +88,4 @@ foo
90
88
  </tr>
91
89
  </table>
92
90
  <hr />
93
- <div>
94
- </div>
91
+ <div></div>
@@ -17,7 +17,6 @@ Embedded? one af"t"er another!
17
17
  <p>Embedded? true!</p>
18
18
  <p>Embedded? twice! true!</p>
19
19
  <p>Embedded? one af"t"er another!</p>
20
- <div class='render'><em>wow!</em></div>
21
20
  stuff followed by whitespace
22
21
  <strong>block with whitespace</strong>
23
22
  <p>
@@ -59,6 +58,5 @@ testtest
59
58
  <p class='article foo' id='article_1'>Blah</p>
60
59
  <p class='article quux qux' id='article_1'>Blump</p>
61
60
  Woah inner quotes
62
- <p class='dynamic_quote' dyn='3' quotes="single '">
63
- </p>
61
+ <p class='dynamic_quote' dyn='3' quotes="single '"></p>
64
62
  <p class='dynamic_self_closing' dyn='3' />