merbjedi-haml 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/FAQ +138 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +332 -0
  4. data/REVISION +1 -0
  5. data/Rakefile +184 -0
  6. data/VERSION +1 -0
  7. data/bin/css2sass +7 -0
  8. data/bin/haml +9 -0
  9. data/bin/html2haml +7 -0
  10. data/bin/sass +8 -0
  11. data/extra/haml-mode.el +434 -0
  12. data/extra/sass-mode.el +98 -0
  13. data/init.rb +8 -0
  14. data/lib/haml.rb +1025 -0
  15. data/lib/haml/buffer.rb +255 -0
  16. data/lib/haml/engine.rb +268 -0
  17. data/lib/haml/error.rb +22 -0
  18. data/lib/haml/exec.rb +395 -0
  19. data/lib/haml/filters.rb +276 -0
  20. data/lib/haml/helpers.rb +465 -0
  21. data/lib/haml/helpers/action_view_extensions.rb +45 -0
  22. data/lib/haml/helpers/action_view_mods.rb +181 -0
  23. data/lib/haml/html.rb +218 -0
  24. data/lib/haml/precompiler.rb +896 -0
  25. data/lib/haml/shared.rb +45 -0
  26. data/lib/haml/template.rb +51 -0
  27. data/lib/haml/template/patch.rb +58 -0
  28. data/lib/haml/template/plugin.rb +72 -0
  29. data/lib/haml/util.rb +77 -0
  30. data/lib/haml/version.rb +47 -0
  31. data/lib/sass.rb +1062 -0
  32. data/lib/sass/css.rb +388 -0
  33. data/lib/sass/engine.rb +501 -0
  34. data/lib/sass/environment.rb +33 -0
  35. data/lib/sass/error.rb +35 -0
  36. data/lib/sass/plugin.rb +203 -0
  37. data/lib/sass/plugin/merb.rb +56 -0
  38. data/lib/sass/plugin/rails.rb +24 -0
  39. data/lib/sass/repl.rb +44 -0
  40. data/lib/sass/script.rb +38 -0
  41. data/lib/sass/script/bool.rb +13 -0
  42. data/lib/sass/script/color.rb +97 -0
  43. data/lib/sass/script/funcall.rb +28 -0
  44. data/lib/sass/script/functions.rb +122 -0
  45. data/lib/sass/script/lexer.rb +144 -0
  46. data/lib/sass/script/literal.rb +60 -0
  47. data/lib/sass/script/number.rb +231 -0
  48. data/lib/sass/script/operation.rb +30 -0
  49. data/lib/sass/script/parser.rb +142 -0
  50. data/lib/sass/script/string.rb +42 -0
  51. data/lib/sass/script/unary_operation.rb +21 -0
  52. data/lib/sass/script/variable.rb +20 -0
  53. data/lib/sass/tree/attr_node.rb +64 -0
  54. data/lib/sass/tree/comment_node.rb +30 -0
  55. data/lib/sass/tree/debug_node.rb +22 -0
  56. data/lib/sass/tree/directive_node.rb +50 -0
  57. data/lib/sass/tree/file_node.rb +27 -0
  58. data/lib/sass/tree/for_node.rb +29 -0
  59. data/lib/sass/tree/if_node.rb +27 -0
  60. data/lib/sass/tree/mixin_def_node.rb +18 -0
  61. data/lib/sass/tree/mixin_node.rb +34 -0
  62. data/lib/sass/tree/node.rb +97 -0
  63. data/lib/sass/tree/rule_node.rb +120 -0
  64. data/lib/sass/tree/variable_node.rb +24 -0
  65. data/lib/sass/tree/while_node.rb +20 -0
  66. data/rails/init.rb +1 -0
  67. data/test/benchmark.rb +99 -0
  68. data/test/haml/engine_test.rb +852 -0
  69. data/test/haml/helper_test.rb +224 -0
  70. data/test/haml/html2haml_test.rb +92 -0
  71. data/test/haml/markaby/standard.mab +52 -0
  72. data/test/haml/mocks/article.rb +6 -0
  73. data/test/haml/results/content_for_layout.xhtml +15 -0
  74. data/test/haml/results/eval_suppressed.xhtml +9 -0
  75. data/test/haml/results/filters.xhtml +62 -0
  76. data/test/haml/results/helpers.xhtml +93 -0
  77. data/test/haml/results/helpful.xhtml +10 -0
  78. data/test/haml/results/just_stuff.xhtml +68 -0
  79. data/test/haml/results/list.xhtml +12 -0
  80. data/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
  81. data/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
  82. data/test/haml/results/original_engine.xhtml +20 -0
  83. data/test/haml/results/partial_layout.xhtml +5 -0
  84. data/test/haml/results/partials.xhtml +21 -0
  85. data/test/haml/results/render_layout.xhtml +3 -0
  86. data/test/haml/results/silent_script.xhtml +74 -0
  87. data/test/haml/results/standard.xhtml +42 -0
  88. data/test/haml/results/tag_parsing.xhtml +23 -0
  89. data/test/haml/results/very_basic.xhtml +5 -0
  90. data/test/haml/results/whitespace_handling.xhtml +89 -0
  91. data/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  92. data/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  93. data/test/haml/rhtml/action_view.rhtml +62 -0
  94. data/test/haml/rhtml/standard.rhtml +54 -0
  95. data/test/haml/template_test.rb +204 -0
  96. data/test/haml/templates/_av_partial_1.haml +9 -0
  97. data/test/haml/templates/_av_partial_1_ugly.haml +9 -0
  98. data/test/haml/templates/_av_partial_2.haml +5 -0
  99. data/test/haml/templates/_av_partial_2_ugly.haml +5 -0
  100. data/test/haml/templates/_layout.erb +3 -0
  101. data/test/haml/templates/_layout_for_partial.haml +3 -0
  102. data/test/haml/templates/_partial.haml +8 -0
  103. data/test/haml/templates/_text_area.haml +3 -0
  104. data/test/haml/templates/action_view.haml +47 -0
  105. data/test/haml/templates/action_view_ugly.haml +47 -0
  106. data/test/haml/templates/breakage.haml +8 -0
  107. data/test/haml/templates/content_for_layout.haml +10 -0
  108. data/test/haml/templates/eval_suppressed.haml +11 -0
  109. data/test/haml/templates/filters.haml +66 -0
  110. data/test/haml/templates/helpers.haml +95 -0
  111. data/test/haml/templates/helpful.haml +11 -0
  112. data/test/haml/templates/just_stuff.haml +83 -0
  113. data/test/haml/templates/list.haml +12 -0
  114. data/test/haml/templates/nuke_inner_whitespace.haml +32 -0
  115. data/test/haml/templates/nuke_outer_whitespace.haml +144 -0
  116. data/test/haml/templates/original_engine.haml +17 -0
  117. data/test/haml/templates/partial_layout.haml +3 -0
  118. data/test/haml/templates/partialize.haml +1 -0
  119. data/test/haml/templates/partials.haml +12 -0
  120. data/test/haml/templates/render_layout.haml +2 -0
  121. data/test/haml/templates/silent_script.haml +40 -0
  122. data/test/haml/templates/standard.haml +42 -0
  123. data/test/haml/templates/standard_ugly.haml +42 -0
  124. data/test/haml/templates/tag_parsing.haml +21 -0
  125. data/test/haml/templates/very_basic.haml +4 -0
  126. data/test/haml/templates/whitespace_handling.haml +87 -0
  127. data/test/linked_rails.rb +12 -0
  128. data/test/sass/css2sass_test.rb +193 -0
  129. data/test/sass/engine_test.rb +752 -0
  130. data/test/sass/functions_test.rb +96 -0
  131. data/test/sass/more_results/more1.css +9 -0
  132. data/test/sass/more_results/more1_with_line_comments.css +26 -0
  133. data/test/sass/more_results/more_import.css +29 -0
  134. data/test/sass/more_templates/_more_partial.sass +2 -0
  135. data/test/sass/more_templates/more1.sass +23 -0
  136. data/test/sass/more_templates/more_import.sass +11 -0
  137. data/test/sass/plugin_test.rb +208 -0
  138. data/test/sass/results/alt.css +4 -0
  139. data/test/sass/results/basic.css +9 -0
  140. data/test/sass/results/compact.css +5 -0
  141. data/test/sass/results/complex.css +87 -0
  142. data/test/sass/results/compressed.css +1 -0
  143. data/test/sass/results/expanded.css +19 -0
  144. data/test/sass/results/import.css +29 -0
  145. data/test/sass/results/line_numbers.css +49 -0
  146. data/test/sass/results/mixins.css +95 -0
  147. data/test/sass/results/multiline.css +24 -0
  148. data/test/sass/results/nested.css +22 -0
  149. data/test/sass/results/parent_ref.css +13 -0
  150. data/test/sass/results/script.css +16 -0
  151. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  152. data/test/sass/results/subdir/subdir.css +3 -0
  153. data/test/sass/results/units.css +11 -0
  154. data/test/sass/script_test.rb +152 -0
  155. data/test/sass/templates/_partial.sass +2 -0
  156. data/test/sass/templates/alt.sass +16 -0
  157. data/test/sass/templates/basic.sass +23 -0
  158. data/test/sass/templates/bork.sass +2 -0
  159. data/test/sass/templates/bork2.sass +2 -0
  160. data/test/sass/templates/compact.sass +17 -0
  161. data/test/sass/templates/complex.sass +309 -0
  162. data/test/sass/templates/compressed.sass +15 -0
  163. data/test/sass/templates/expanded.sass +17 -0
  164. data/test/sass/templates/import.sass +11 -0
  165. data/test/sass/templates/importee.sass +19 -0
  166. data/test/sass/templates/line_numbers.sass +13 -0
  167. data/test/sass/templates/mixins.sass +76 -0
  168. data/test/sass/templates/multiline.sass +20 -0
  169. data/test/sass/templates/nested.sass +25 -0
  170. data/test/sass/templates/parent_ref.sass +25 -0
  171. data/test/sass/templates/script.sass +101 -0
  172. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +2 -0
  173. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  174. data/test/sass/templates/subdir/subdir.sass +6 -0
  175. data/test/sass/templates/units.sass +11 -0
  176. data/test/test_helper.rb +21 -0
  177. metadata +273 -0
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'haml/template'
4
+
5
+ class ActionView::Base
6
+ def nested_tag
7
+ content_tag(:span) {content_tag(:div) {"something"}}
8
+ end
9
+ end
10
+
11
+ class HelperTest < Test::Unit::TestCase
12
+ Post = Struct.new('Post', :body)
13
+
14
+ def setup
15
+ @base = ActionView::Base.new
16
+ @base.controller = ActionController::Base.new
17
+ @base.instance_variable_set('@post', Post.new("Foo bar\nbaz"))
18
+ end
19
+
20
+ def render(text, options = {})
21
+ if options == :action_view
22
+ @base.render :inline => text, :type => :haml
23
+ else
24
+ scope = options.delete :scope_object
25
+ Haml::Engine.new(text, options).to_html(scope ? scope : Object.new)
26
+ end
27
+ end
28
+
29
+ def test_flatten
30
+ assert_equal("FooBar", Haml::Helpers.flatten("FooBar"))
31
+
32
+ assert_equal("FooBar", Haml::Helpers.flatten("Foo\rBar"))
33
+
34
+ assert_equal("Foo&#x000A;Bar", Haml::Helpers.flatten("Foo\nBar"))
35
+
36
+ assert_equal("Hello&#x000A;World!&#x000A;YOU ARE FLAT?&#x000A;OMGZ!",
37
+ Haml::Helpers.flatten("Hello\nWorld!\nYOU ARE \rFLAT?\n\rOMGZ!"))
38
+ end
39
+
40
+ def test_list_of_should_render_correctly
41
+ assert_equal("<li>1</li>\n<li>2</li>\n", render("= list_of([1, 2]) do |i|\n = i"))
42
+ assert_equal("<li>[1]</li>\n", render("= list_of([[1]]) do |i|\n = i.inspect"))
43
+ assert_equal("<li>\n <h1>Fee</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fi</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fo</h1>\n <p>A word!</p>\n</li>\n<li>\n <h1>Fum</h1>\n <p>A word!</p>\n</li>\n",
44
+ render("= list_of(['Fee', 'Fi', 'Fo', 'Fum']) do |title|\n %h1= title\n %p A word!"))
45
+ end
46
+
47
+ def test_buffer_access
48
+ assert(render("= buffer") =~ /#<Haml::Buffer:0x[a-z0-9]+>/)
49
+ assert_equal(render("= (buffer == _hamlout)"), "true\n")
50
+ end
51
+
52
+ def test_tabs
53
+ assert_equal("foo\n bar\nbaz\n", render("foo\n- tab_up\nbar\n- tab_down\nbaz"))
54
+ assert_equal(" <p>tabbed</p>\n", render("- buffer.tabulation=5\n%p tabbed"))
55
+ end
56
+
57
+ def test_helpers_dont_leak
58
+ # Haml helpers shouldn't be accessible from ERB
59
+ render("foo")
60
+ proper_behavior = false
61
+
62
+ begin
63
+ ActionView::Base.new.render(:inline => "<%= flatten('Foo\\nBar') %>")
64
+ rescue NoMethodError
65
+ proper_behavior = true
66
+ end
67
+ assert(proper_behavior)
68
+
69
+ begin
70
+ ActionView::Base.new.render(:inline => "<%= concat('foo') %>")
71
+ rescue ArgumentError, NameError
72
+ proper_behavior = true
73
+ end
74
+ assert(proper_behavior)
75
+ end
76
+
77
+ def test_action_view_included
78
+ assert(Haml::Helpers.action_view?)
79
+ end
80
+
81
+ def test_form_tag
82
+ # This is usually provided by ActionController::Base.
83
+ def @base.protect_against_forgery?; false; end
84
+ result = render("- form_tag 'foo' do\n %p bar\n %strong baz", :action_view)
85
+ should_be = "<form action=\"foo\" method=\"post\">\n <p>bar</p>\n <strong>baz</strong>\n</form>\n"
86
+ assert_equal(should_be, result)
87
+ end
88
+
89
+ def test_text_area
90
+ assert_equal(%(<textarea id="body" name="body">Foo&#x000A;Bar&#x000A; Baz&#x000A; Boom</textarea>\n),
91
+ render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view))
92
+
93
+ assert_equal(%(<textarea cols="40" id="post_body" name="post[body]" rows="20">Foo bar&#x000A;baz</textarea>\n),
94
+ render('= text_area :post, :body', :action_view))
95
+
96
+ assert_equal(%(<pre>Foo bar&#x000A; baz</pre>\n),
97
+ render('= content_tag "pre", "Foo bar\n baz"', :action_view))
98
+ end
99
+
100
+ def test_capture_haml
101
+ assert_equal("\"<p>13</p>\\n\"\n", render("- foo = capture_haml(13) do |a|\n %p= a\n= foo.dump"))
102
+ end
103
+
104
+ def test_content_tag_block
105
+ assert_equal(<<HTML.strip, render(<<HAML, :action_view))
106
+ <div><p>bar</p>
107
+ <strong>bar</strong>
108
+ </div>
109
+ HTML
110
+ - content_tag :div do
111
+ %p bar
112
+ %strong bar
113
+ HAML
114
+ end
115
+
116
+ def test_haml_tag_attribute_html_escaping
117
+ assert_equal("<p id='foo&amp;bar'>baz</p>\n", render("%p{:id => 'foo&bar'} baz", :escape_html => true))
118
+ end
119
+
120
+ def test_haml_tag_autoclosed_tags_are_closed
121
+ assert_equal("<br class='foo' />\n", render("- haml_tag :br, :class => 'foo'"))
122
+ end
123
+
124
+ def test_haml_tag_non_autoclosed_tags_arent_closed
125
+ assert_equal("<p></p>\n", render("- haml_tag :p"))
126
+ end
127
+
128
+ def test_haml_tag_renders_text_on_a_single_line
129
+ assert_equal("<p>#{'a' * 100}</p>\n", render("- haml_tag :p, 'a' * 100"))
130
+ end
131
+
132
+ def test_haml_tag_raises_error_for_multiple_content
133
+ assert_raise(Haml::Error) { render("- haml_tag :p, 'foo' do\n bar") }
134
+ end
135
+
136
+ def test_haml_tag_flags
137
+ assert_equal("<p />\n", render("- haml_tag :p, :/"))
138
+ assert_equal("<p>kumquat</p>\n", render("- haml_tag :p, :< do\n kumquat"))
139
+
140
+ assert_raise(Haml::Error) { render("- haml_tag :p, 'foo', :/") }
141
+ assert_raise(Haml::Error) { render("- haml_tag :p, :/ do\n foo") }
142
+ end
143
+
144
+ def test_is_haml
145
+ assert(!ActionView::Base.new.is_haml?)
146
+ assert_equal("true\n", render("= is_haml?"))
147
+ assert_equal("true\n", render("= is_haml?", :action_view))
148
+ assert_equal("false", @base.render(:inline => '<%= is_haml? %>'))
149
+ assert_equal("false\n", render("= render :inline => '<%= is_haml? %>'", :action_view))
150
+ end
151
+
152
+ def test_page_class
153
+ controller = Struct.new(:controller_name, :action_name).new('troller', 'tion')
154
+ scope = Struct.new(:controller).new(controller)
155
+ result = render("%div{:class => page_class} MyDiv", :scope_object => scope)
156
+ expected = "<div class='troller tion'>MyDiv</div>\n"
157
+ assert_equal expected, result
158
+ end
159
+
160
+ def test_indented_capture
161
+ assert_equal(" \n Foo\n ", @base.render(:inline => " <% res = capture do %>\n Foo\n <% end %><%= res %>"))
162
+ end
163
+
164
+ def test_capture_deals_properly_with_collections
165
+ Haml::Helpers.module_eval do
166
+ def trc(collection, &block)
167
+ collection.each do |record|
168
+ haml_concat capture_haml(record, &block)
169
+ end
170
+ end
171
+ end
172
+
173
+ assert_equal("1\n\n2\n\n3\n\n", render("- trc([1, 2, 3]) do |i|\n = i.inspect"))
174
+ end
175
+
176
+ def test_find_and_preserve_with_block
177
+ assert_equal("<pre>Foo&#x000A;Bar</pre>\nFoo\nBar\n",
178
+ render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
179
+ end
180
+
181
+ def test_preserve_with_block
182
+ assert_equal("<pre>Foo&#x000A;Bar</pre>&#x000A;Foo&#x000A;Bar\n",
183
+ render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
184
+ end
185
+
186
+ def test_init_haml_helpers
187
+ context = Object.new
188
+ class << context
189
+ include Haml::Helpers
190
+ end
191
+ context.init_haml_helpers
192
+
193
+ result = context.capture_haml do
194
+ context.haml_tag :p, :attr => "val" do
195
+ context.haml_concat "Blah"
196
+ end
197
+ end
198
+
199
+ assert_equal("<p attr='val'>\n Blah\n</p>\n", result)
200
+ end
201
+
202
+ def test_non_haml
203
+ assert_equal("false\n", render("= non_haml { is_haml? }"))
204
+ end
205
+
206
+ def test_content_tag_nested
207
+ assert_equal "<span><div>something</div></span>", render("= nested_tag", :action_view).strip
208
+ end
209
+
210
+ class ActsLikeTag
211
+ # We want to be able to have people include monkeypatched ActionView helpers
212
+ # without redefining is_haml?.
213
+ # This is accomplished via Object#is_haml?, and this is a test for it.
214
+ include ActionView::Helpers::TagHelper
215
+ def to_s
216
+ content_tag :p, 'some tag content'
217
+ end
218
+ end
219
+
220
+ def test_random_class_includes_tag_helper
221
+ assert_equal "<p>some tag content</p>", ActsLikeTag.new.to_s
222
+ end
223
+ end
224
+
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../test_helper'
3
+ require 'haml/html'
4
+
5
+ class Html2HamlTest < Test::Unit::TestCase
6
+
7
+ def test_empty_render_should_remain_empty
8
+ assert_equal '', render('')
9
+ end
10
+
11
+ def test_id_and_class_should_be_removed_from_hash
12
+ assert_equal '%span#foo.bar', render('<span id="foo" class="bar"> </span>')
13
+ end
14
+
15
+ def test_no_tag_name_for_div_if_class_or_id_is_present
16
+ assert_equal '#foo', render('<div id="foo"> </div>')
17
+ assert_equal '.foo', render('<div class="foo"> </div>')
18
+ end
19
+
20
+ def test_multiple_class_names
21
+ assert_equal '.foo.bar.baz', render('<div class=" foo bar baz "> </div>')
22
+ end
23
+
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
+ end
30
+
31
+ def test_sqml_comment
32
+ assert_equal "/\n IE sucks", render('<!-- IE sucks -->')
33
+ end
34
+
35
+ def test_rhtml
36
+ assert_equal '- foo = bar', render_rhtml('<% foo = bar %>')
37
+ assert_equal '- foo = bar', render_rhtml('<% foo = bar -%>')
38
+ assert_equal '= h @item.title', render_rhtml('<%=h @item.title %>')
39
+ assert_equal '= h @item.title', render_rhtml('<%=h @item.title -%>')
40
+ end
41
+
42
+ def test_rhtml_with_html_special_chars
43
+ assert_equal '= 3 < 5 ? "OK" : "Your computer is b0rken"',
44
+ render_rhtml(%Q{<%= 3 < 5 ? "OK" : "Your computer is b0rken" %>})
45
+ end
46
+
47
+ def test_rhtml_in_class_attribute
48
+ assert_equal "%div{ :class => dyna_class }\n I have a dynamic attribute",
49
+ render_rhtml(%Q{<div class="<%= dyna_class %>">I have a dynamic attribute</div>})
50
+ end
51
+
52
+ def test_rhtml_in_id_attribute
53
+ assert_equal "%div{ :id => dyna_id }\n I have a dynamic attribute",
54
+ render_rhtml(%Q{<div id="<%= dyna_id %>">I have a dynamic attribute</div>})
55
+ end
56
+
57
+ def test_rhtml_in_attribute_results_in_string_interpolation
58
+ assert_equal %(%div{ :id => "item_\#{i}" }\n Ruby string interpolation FTW),
59
+ render_rhtml(%Q{<div id="item_<%= i %>">Ruby string interpolation FTW</div>})
60
+ end
61
+
62
+ def test_rhtml_in_attribute_with_trailing_content
63
+ assert_equal %(%div{ :class => "\#{12}!" }\n Bang!),
64
+ render_rhtml(%Q{<div class="<%= 12 %>!">Bang!</div>})
65
+ end
66
+
67
+ def test_rhtml_in_attribute_to_multiple_interpolations
68
+ assert_equal %(%div{ :class => "\#{12} + \#{13}" }\n Math is super),
69
+ render_rhtml(%Q{<div class="<%= 12 %> + <%= 13 %>">Math is super</div>})
70
+ end
71
+
72
+ def test_whitespace_eating_erb_tags
73
+ assert_equal %(- form_for),
74
+ render_rhtml(%Q{<%- form_for -%>})
75
+ end
76
+
77
+ protected
78
+
79
+ def render(text, options = {})
80
+ Haml::HTML.new(text, options).render.rstrip
81
+ end
82
+
83
+ def render_rhtml(text)
84
+ render(text, :rhtml => true)
85
+ end
86
+
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
92
+ end
@@ -0,0 +1,52 @@
1
+ self << '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
2
+ html(:xmlns=>'http://www.w3.org/1999/xhtml', 'xml:lang'=>'en-US') do
3
+ head do
4
+ title "Hampton Catlin Is Totally Awesome"
5
+ meta("http-equiv" => "Content-Type", :content => "text/html; charset=utf-8")
6
+ end
7
+ body do
8
+ # You're In my house now!
9
+ div :class => "header" do
10
+ self << %|Yes, ladies and gentileman. He is just that egotistical.
11
+ Fantastic! This should be multi-line output
12
+ The question is if this would translate! Ahah!|
13
+ self << 1 + 9 + 8 + 2 #numbers should work and this should be ignored
14
+ end
15
+ div(:id => "body") { self << "Quotes should be loved! Just like people!"}
16
+ 120.times do |number|
17
+ number
18
+ end
19
+ self << "Wow.|"
20
+ p do
21
+ self << "Holy cow " +
22
+ "multiline " +
23
+ "tags! " +
24
+ "A pipe (|) even!"
25
+ self << [1, 2, 3].collect { |n| "PipesIgnored|" }
26
+ self << [1, 2, 3].collect { |n|
27
+ n.to_s
28
+ }.join("|")
29
+ end
30
+ div(:class => "silent") do
31
+ foo = String.new
32
+ foo << "this"
33
+ foo << " shouldn't"
34
+ foo << " evaluate"
35
+ self << foo + " but now it should!"
36
+ # Woah crap a comment!
37
+ end
38
+ # That was a line that shouldn't close everything.
39
+ ul(:class => "really cool") do
40
+ ('a'..'f').each do |a|
41
+ li a
42
+ end
43
+ end
44
+ div((@should_eval = "with this text"), :id => "combo", :class => "of_divs_with_underscore")
45
+ [ 104, 101, 108, 108, 111 ].map do |byte|
46
+ byte.chr
47
+ end
48
+ div(:class => "footer") do
49
+ strong("This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works", :class => "shout")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,6 @@
1
+ class Article
2
+ attr_accessor :id, :title, :body
3
+ def initialize
4
+ @id, @title, @body = 1, 'Hello', 'World'
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head></head>
4
+ <body>
5
+ <div id='content'>
6
+ Lorem ipsum dolor sit amet
7
+ </div>
8
+ <div id='yieldy'>
9
+ Lorem ipsum dolor sit amet
10
+ </div>
11
+ <div id='nosym'>
12
+ Lorem ipsum dolor sit amet
13
+ </div>
14
+ </body>
15
+ </html>
@@ -0,0 +1,9 @@
1
+ <p></p>
2
+ <p></p>
3
+ <h1>Me!</h1>
4
+ <div id='foo'>
5
+ <p id='bar'>All</p>
6
+ <br />
7
+ <p class='baz'>This</p>
8
+ Should render
9
+ </div>
@@ -0,0 +1,62 @@
1
+ <style>
2
+ /* line 1 */
3
+ p { border-style: dotted; border-width: 22px; border-color: #ff00ff; }
4
+
5
+ /* line 6 */
6
+ h1 { font-weight: normal; }
7
+ </style>
8
+ TESTING HAHAHAHA!
9
+ <p>
10
+ <script type='text/javascript'>
11
+ //<![CDATA[
12
+ function newline(str) {
13
+ return "\n" + str;
14
+ }
15
+ //]]>
16
+ </script>
17
+ </p>
18
+ This
19
+ Is
20
+ Plain
21
+ Text
22
+ %strong right?
23
+ #{not interpolated}
24
+ \3
25
+ \#{also not}
26
+ \\
27
+ <p>
28
+ <pre>This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work?
29
+ This one is, too.&#x000A;Nested, that is.&#x000A;</pre>
30
+ </p>
31
+ <ul>
32
+
33
+ <li>a</li>
34
+
35
+ <li>b</li>
36
+
37
+ <li>c</li>
38
+
39
+ <li>d</li>
40
+
41
+ <li>e</li>
42
+
43
+ <li>f</li>
44
+
45
+ <li>g</li>
46
+
47
+ <li>h</li>
48
+
49
+ <li>i</li>
50
+
51
+ <li>j</li>
52
+
53
+
54
+
55
+ </ul>
56
+ <div class='res'>178</div>
57
+ Text!
58
+ Hello, World!
59
+ How are you doing today?
60
+ &lt;div class=&quot;foo&quot;&gt;
61
+ &lt;p&gt;I think &amp;mdash; or do I?&lt;/p&gt;
62
+ &lt;/div&gt;