hamlet 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,9 +3,9 @@ require 'helper'
3
3
  class TestSlimEmbeddedEngines < TestSlim
4
4
  def test_render_with_erb
5
5
  source = %q{
6
- p
6
+ <p
7
7
  - text = 'before erb block'
8
- erb:
8
+ <erb:
9
9
  <b>Hello from <%= text.upcase %>!</b>
10
10
  Second Line!
11
11
  <% if true %><%= true %><% end %>
@@ -17,7 +17,7 @@ p
17
17
  def test_render_with_markdown
18
18
  # Keep the trailing spaces.
19
19
  source = %q{
20
- markdown:
20
+ <markdown:
21
21
  #Header
22
22
  Hello from #{"Markdown!"}
23
23
 
@@ -37,7 +37,7 @@ markdown:
37
37
 
38
38
  def test_render_with_creole
39
39
  source = %q{
40
- creole:
40
+ <creole:
41
41
  = head1
42
42
  == head2
43
43
  }
@@ -46,7 +46,7 @@ creole:
46
46
 
47
47
  def test_render_with_builder
48
48
  source = %q{
49
- builder:
49
+ <builder:
50
50
  xml.p(:id => 'test') {
51
51
  xml.text!('Hello')
52
52
  }
@@ -56,7 +56,7 @@ builder:
56
56
 
57
57
  def test_render_with_wiki
58
58
  source = %q{
59
- wiki:
59
+ <wiki:
60
60
  = head1
61
61
  == head2
62
62
  }
@@ -66,12 +66,12 @@ wiki:
66
66
  def test_render_with_javascript
67
67
  # Keep the trailing space behind "javascript: "!
68
68
  source = %q{
69
- javascript:
69
+ <javascript:
70
70
  $(function() {});
71
71
 
72
72
 
73
73
  alert('hello')
74
- p Hi
74
+ <p>Hi
75
75
  }
76
76
  assert_html %{<script type="text/javascript">$(function() {});\n\n\nalert('hello')</script><p>Hi</p>}, source
77
77
  end
@@ -80,7 +80,7 @@ p Hi
80
80
  # Keep the trailing space behind "javascript: "!
81
81
  source = %q{
82
82
  - func = "alert('hello');"
83
- javascript:
83
+ <javascript:
84
84
  $(function() { #{func} });
85
85
  }
86
86
  assert_html %q|<script type="text/javascript">$(function() { alert('hello'); });</script>|, source
@@ -88,7 +88,7 @@ javascript:
88
88
 
89
89
  def test_render_with_ruby
90
90
  source = %q{
91
- ruby:
91
+ <ruby:
92
92
  variable = 1 +
93
93
  2
94
94
  = variable
@@ -98,7 +98,7 @@ ruby:
98
98
 
99
99
  def test_render_with_scss
100
100
  source = %q{
101
- scss:
101
+ <scss:
102
102
  $color: #f00;
103
103
  body { color: $color; }
104
104
  }
@@ -107,19 +107,19 @@ scss:
107
107
 
108
108
  def test_disabled_embedded_engine
109
109
  source = %{
110
- ruby:
110
+ <ruby:
111
111
  Embedded Ruby
112
112
  }
113
113
  assert_runtime_error 'Embedded engine ruby is disabled', source, :enable_engines => %w(javascript)
114
114
 
115
115
  source = %{
116
- ruby:
116
+ <ruby:
117
117
  Embedded Ruby
118
118
  }
119
119
  assert_runtime_error 'Embedded engine ruby is disabled', source, :enable_engines => %w(javascript)
120
120
 
121
121
  source = %{
122
- ruby:
122
+ <ruby:
123
123
  Embedded Ruby
124
124
  }
125
125
  assert_runtime_error 'Embedded engine ruby is disabled', source, :disable_engines => %w(ruby)
@@ -127,13 +127,13 @@ ruby:
127
127
 
128
128
  def test_enabled_embedded_engine
129
129
  source = %q{
130
- javascript:
130
+ <javascript:
131
131
  $(function() {});
132
132
  }
133
133
  assert_html '<script type="text/javascript">$(function() {});</script>', source, :disable_engines => %w(ruby)
134
134
 
135
135
  source = %q{
136
- javascript:
136
+ <javascript:
137
137
  $(function() {});
138
138
  }
139
139
  assert_html '<script type="text/javascript">$(function() {});</script>', source, :enable_engines => %w(javascript)
@@ -3,18 +3,17 @@ require 'helper'
3
3
  class TestSlimHtmlEscaping < TestSlim
4
4
  def test_html_will_not_be_escaped
5
5
  source = %q{
6
- p <Hello> World, meet "Slim".
6
+ <p> <Hello> World, meet "Slim".
7
7
  }
8
8
 
9
- assert_html '<p><Hello> World, meet "Slim".</p>', source
9
+ assert_html '<p> <Hello> World, meet "Slim".</p>', source
10
10
  end
11
11
 
12
12
  def test_html_with_newline_will_not_be_escaped
13
13
  source = %q{
14
- p
15
- |
16
- <Hello> World,
17
- meet "Slim".
14
+ <p>
15
+ ><Hello> World,
16
+ > meet "Slim".
18
17
  }
19
18
 
20
19
  assert_html "<p><Hello> World,\n meet \"Slim\".</p>", source
@@ -24,7 +23,7 @@ p
24
23
  source = %q{
25
24
  - x = '"'
26
25
  - content = '<x>'
27
- p class="#{x}" test #{content}
26
+ <p class="#{x}">test #{content}
28
27
  }
29
28
 
30
29
  assert_html '<p class="&quot;">test &lt;x&gt;</p>', source
@@ -6,9 +6,9 @@ class TestSlimHtmlStructure < TestSlim
6
6
  source = %q{
7
7
  <html
8
8
  <head
9
- <title Simple Test Title
9
+ <title>Simple Test Title
10
10
  <body
11
- <p Hello World, meet Slim.
11
+ <p>Hello World, meet Slim.
12
12
  }
13
13
 
14
14
  assert_html '<html><head><title>Simple Test Title</title></head><body><p>Hello World, meet Slim.</p></body></html>', source
@@ -17,9 +17,9 @@ class TestSlimHtmlStructure < TestSlim
17
17
  def test_html_tag_with_text_and_empty_line
18
18
  # Keep the trailing space behind "body "!
19
19
  source = %q{
20
- <p Hello
20
+ <p>Hello
21
21
 
22
- <p World
22
+ <p>World
23
23
  }
24
24
 
25
25
  assert_html "<p>Hello</p><p>World</p>", source
@@ -28,7 +28,7 @@ class TestSlimHtmlStructure < TestSlim
28
28
  def test_html_namespaces
29
29
  source = %q{
30
30
  <html:body
31
- html:p html:id="test" Text
31
+ <html:p html:id="test">Text
32
32
  }
33
33
 
34
34
  assert_html '<html:body><html:p html:id="test">Text</html:p></html:body>', source
@@ -36,7 +36,7 @@ class TestSlimHtmlStructure < TestSlim
36
36
 
37
37
  def test_doctype
38
38
  source = %q{
39
- doctype 1.1
39
+ <doctype 1.1
40
40
  <html
41
41
  }
42
42
 
@@ -45,7 +45,7 @@ doctype 1.1
45
45
 
46
46
  def test_doctype_new_syntax
47
47
  source = %q{
48
- doctype 5
48
+ <doctype 5
49
49
  <html
50
50
  }
51
51
 
@@ -54,7 +54,7 @@ doctype 5
54
54
 
55
55
  def test_doctype_new_syntax_html5
56
56
  source = %q{
57
- doctype html
57
+ <doctype html
58
58
  <html
59
59
  }
60
60
 
@@ -63,7 +63,7 @@ doctype html
63
63
 
64
64
  def test_render_with_shortcut_attributes
65
65
  source = %q{
66
- <h1#title This is my title
66
+ <h1#title>This is my title
67
67
  <#notice.hello.world
68
68
  = hello_world
69
69
  }
@@ -93,7 +93,7 @@ doctype html
93
93
  source = %q{
94
94
  <p
95
95
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
96
- <p Some more markup
96
+ <p>Some more markup
97
97
  }
98
98
 
99
99
  assert_html '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p><p>Some more markup</p>', source
@@ -101,22 +101,22 @@ doctype html
101
101
 
102
102
  def test_render_with_text_block_with_trailing_whitespace
103
103
  source = %q{
104
- ' this is
104
+ this is
105
105
  a link to
106
- <a href="link" page
106
+ <a href="link">page
107
107
  }
108
108
 
109
- assert_html "this is\na link to <a href=\"link\">page</a>", source
109
+ assert_html "this is\n a link to<a href=\"link\">page</a>", source
110
110
  end
111
111
 
112
112
  def test_nested_text
113
113
  source = %q{
114
114
  <p
115
- This is line one.
116
- This is line two.
117
- This is line three.
118
- This is line four.
119
- <p This is a new paragraph.
115
+ >This is line one.
116
+ > This is line two.
117
+ > This is line three.
118
+ > This is line four.
119
+ <p>This is a new paragraph.
120
120
  }
121
121
 
122
122
  assert_html "<p>This is line one.\n This is line two.\n This is line three.\n This is line four.</p><p>This is a new paragraph.</p>", source
@@ -126,8 +126,8 @@ doctype html
126
126
  source = %q{
127
127
  <p
128
128
  This is line one.
129
- > This is line two.
130
- span.bold This is a bold line in the paragraph.
129
+ > This is line two.
130
+ <span.bold>This is a bold line in the paragraph.
131
131
  > This is more content.
132
132
  }
133
133
 
@@ -137,10 +137,10 @@ doctype html
137
137
  def test_nested_text_with_nested_html_one_same_line2
138
138
  source = %q{
139
139
  <p
140
- |This is line one.
141
- This is line two.
142
- span.bold This is a bold line in the paragraph.
143
- | This is more content.
140
+ This is line one.
141
+ > This is line two.
142
+ <span.bold>This is a bold line in the paragraph.
143
+ > This is more content.
144
144
  }
145
145
 
146
146
  assert_html "<p>This is line one.\n This is line two.<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
@@ -149,13 +149,12 @@ doctype html
149
149
  def test_nested_text_with_nested_html
150
150
  source = %q{
151
151
  <p
152
- |
153
- This is line one.
154
- This is line two.
155
- This is line three.
156
- This is line four.
157
- span.bold This is a bold line in the paragraph.
158
- | This is more content.
152
+ >This is line one.
153
+ > This is line two.
154
+ > This is line three.
155
+ > This is line four.
156
+ <span.bold>This is a bold line in the paragraph.
157
+ > This is more content.
159
158
  }
160
159
 
161
160
  assert_html "<p>This is line one.\n This is line two.\n This is line three.\n This is line four.<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
@@ -163,7 +162,7 @@ doctype html
163
162
 
164
163
  def test_simple_paragraph_with_padding
165
164
  source = %q{
166
- <p There will be 3 spaces in front of this line.
165
+ <p> There will be 3 spaces in front of this line.
167
166
  }
168
167
 
169
168
  assert_html '<p> There will be 3 spaces in front of this line.</p>', source
@@ -171,8 +170,8 @@ doctype html
171
170
 
172
171
  def test_paragraph_with_nested_text
173
172
  source = %q{
174
- <p This is line one.
175
- This is line two.
173
+ <p>This is line one.
174
+ > This is line two.
176
175
  }
177
176
 
178
177
  assert_html "<p>This is line one.\n This is line two.</p>", source
@@ -180,8 +179,8 @@ doctype html
180
179
 
181
180
  def test_paragraph_with_padded_nested_text
182
181
  source = %q{
183
- <p This is line one.
184
- This is line two.
182
+ <p> This is line one.
183
+ > This is line two.
185
184
  }
186
185
 
187
186
  assert_html "<p> This is line one.\n This is line two.</p>", source
@@ -190,7 +189,7 @@ doctype html
190
189
  def test_paragraph_with_attributes_and_nested_text
191
190
  source = %q{
192
191
  <p#test class="paragraph">This is line one.
193
- This is line two.
192
+ This is line two.
194
193
  }
195
194
 
196
195
  assert_html "<p class=\"paragraph\" id=\"test\">This is line one.\nThis is line two.</p>", source
@@ -198,12 +197,12 @@ doctype html
198
197
 
199
198
  def test_output_code_with_leading_spaces
200
199
  source = %q{
201
- <p= hello_world
202
- <p = hello_world
203
- <p = hello_world
200
+ <p>= hello_world
201
+ <p> = hello_world
202
+ <p> =hello_world
204
203
  }
205
204
 
206
- assert_html '<p>Hello World from @env</p><p>Hello World from @env</p><p>Hello World from @env</p>', source
205
+ assert_html '<p>Hello World from @env</p><p> = hello_world</p><p> =hello_world</p>', source
207
206
  end
208
207
 
209
208
  def test_single_quoted_attributes
@@ -259,7 +258,7 @@ doctype html
259
258
  <p id="marvin" class="martian" data-info="Illudium Q-36"> = output_number
260
259
  }
261
260
 
262
- assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
261
+ assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin"> = output_number</p>', source
263
262
  end
264
263
 
265
264
  def test_parens_around_attributes_with_equal_sign_snug_to_right_paren
@@ -283,12 +282,12 @@ doctype html
283
282
  <p id="marvin" class=nil other_empty=#{"".to_s} data-info="Illudium Q-36">= output_number
284
283
  }
285
284
 
286
- assert_html '<p data-info="Illudium Q-36" id="marvin">1337</p>', source
285
+ assert_html '<p class="nil" data-info="Illudium Q-36" id="marvin">1337</p>', source
287
286
  end
288
287
 
289
288
  def test_closed_tag
290
289
  source = %q{
291
- <closed/
290
+ <closed/>
292
291
  }
293
292
 
294
293
  assert_html '<closed />', source, :format => :xhtml
@@ -311,7 +310,7 @@ doctype html
311
310
 
312
311
  def test_closed_tag_with_attributes
313
312
  source = %q{
314
- closed id="test" /
313
+ <closed id="test" />
315
314
  }
316
315
 
317
316
  assert_html '<closed id="test" />', source, :format => :xhtml
@@ -319,7 +318,7 @@ closed id="test" /
319
318
 
320
319
  def test_closed_tag_with_attributes_and_parens
321
320
  source = %q{
322
- <closed id="test">/
321
+ <closed id="test"/>
323
322
  }
324
323
 
325
324
  assert_html '<closed id="test" />', source, :format => :xhtml
@@ -327,11 +326,11 @@ closed id="test" /
327
326
 
328
327
  def test_render_with_html_comments
329
328
  source = %q{
330
- <p Hello
331
- /! This is a comment
329
+ <p>Hello
330
+ <!-- This is a comment
332
331
 
333
332
  Another comment
334
- <p World
333
+ <p>World
335
334
  }
336
335
 
337
336
  assert_html "<p>Hello</p><!--This is a comment\n\nAnother comment--><p>World</p>", source
@@ -339,8 +338,8 @@ closed id="test" /
339
338
 
340
339
  def test_render_with_html_conditional_and_tag
341
340
  source = %q{
342
- /[ if IE ]
343
- p Get a better browser.
341
+ #[ if IE ]
342
+ <p>Get a better browser.
344
343
  }
345
344
 
346
345
  assert_html "<!--[if IE]><p>Get a better browser.</p><![endif]-->", source
@@ -348,7 +347,7 @@ closed id="test" /
348
347
 
349
348
  def test_render_with_html_conditional_and_method_output
350
349
  source = %q{
351
- /[ if IE ]
350
+ #[ if IE ]
352
351
  = message 'hello'
353
352
  }
354
353
 
@@ -3,7 +3,7 @@ require 'helper'
3
3
  class TestParserErrors < TestSlim
4
4
  def test_correct_filename
5
5
  source = %q{
6
- doctype 5
6
+ <doctype 5
7
7
  div Invalid
8
8
  }
9
9
 
@@ -12,7 +12,7 @@ doctype 5
12
12
 
13
13
  def test_unexpected_indentation
14
14
  source = %q{
15
- doctype 5
15
+ <doctype 5
16
16
  div Invalid
17
17
  }
18
18
 
@@ -21,9 +21,9 @@ doctype 5
21
21
 
22
22
  def test_unexpected_text_indentation
23
23
  source = %q{
24
- p
25
- | text block
26
- text
24
+ <p
25
+ text block
26
+ text
27
27
  }
28
28
 
29
29
  assert_syntax_error "Unexpected text indentation\n (__TEMPLATE__), Line 4\n text\n ^\n", source
@@ -31,9 +31,9 @@ p
31
31
 
32
32
  def test_malformed_indentation
33
33
  source = %q{
34
- p
35
- div Valid
36
- div Invalid
34
+ <p
35
+ <div Valid
36
+ <div Invalid
37
37
  }
38
38
 
39
39
  assert_syntax_error "Malformed indentation\n (__TEMPLATE__), Line 4\n div Invalid\n ^\n", source
@@ -41,38 +41,40 @@ p
41
41
 
42
42
  def test_unknown_line_indicator
43
43
  source = %q{
44
- p
45
- div Valid
46
- .valid
47
- #valid
48
- ?invalid
44
+ <p
45
+ <div Valid
46
+ <.valid
47
+ <#valid
48
+ <?invalid
49
49
  }
50
50
 
51
- assert_syntax_error "Unknown line indicator\n (__TEMPLATE__), Line 6\n ?invalid\n ^\n", source
51
+ assert_syntax_error "Unknown line indicator\n (__TEMPLATE__), Line 6\n <?invalid\n ^\n", source
52
52
  end
53
53
 
54
+ =begin
54
55
  def test_expected_closing_delimiter
55
56
  source = %q{
56
- p
57
+ <p
57
58
  img(src="img.jpg" title={title}
58
59
  }
59
60
 
60
61
  assert_syntax_error "Expected closing delimiter )\n (__TEMPLATE__), Line 3\n img(src=\"img.jpg\" title={title}\n ^\n", source
61
62
  end
63
+ =end
62
64
 
63
65
  def test_expected_closing_attribute_delimiter
64
- source = %q{
65
- p
66
- img src=[hash[1] + hash[2]
67
- }
66
+ source = %q!
67
+ <p
68
+ <img src=#{hash[1] + hash[2]}
69
+ !
68
70
 
69
71
  assert_syntax_error "Expected closing attribute delimiter ]\n (__TEMPLATE__), Line 3\n img src=[hash[1] + hash[2]\n ^\n", source
70
72
  end
71
73
 
72
74
  def test_expected_attribute
73
75
  source = %q{
74
- p
75
- img(src='img.png' whatsthis?!)
76
+ <p
77
+ <img src='img.png' whatsthis?!>
76
78
  }
77
79
 
78
80
  assert_syntax_error "Expected attribute\n (__TEMPLATE__), Line 3\n img(src='img.png' whatsthis?!)\n ^\n", source
@@ -80,8 +82,8 @@ p
80
82
 
81
83
  def test_invalid_empty_attribute
82
84
  source = %q{
83
- p
84
- img{src= }
85
+ <p
86
+ <img src= >
85
87
  }
86
88
 
87
89
  assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img{src= }\n ^\n", source
@@ -89,8 +91,8 @@ p
89
91
 
90
92
  def test_invalid_empty_attribute2
91
93
  source = %q{
92
- p
93
- img{src=}
94
+ <p
95
+ <img src=>
94
96
  }
95
97
 
96
98
  assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img{src=}\n ^\n", source
@@ -98,8 +100,8 @@ p
98
100
 
99
101
  def test_invalid_empty_attribute3
100
102
  source = %q{
101
- p
102
- img src=
103
+ <p
104
+ <img src=
103
105
  }
104
106
 
105
107
  assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img src=\n ^\n", source