hamlet 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -82,7 +82,7 @@ A new line is automatically added *after* tags with inner text. If you have mult
82
82
 
83
83
  ## Limitations
84
84
 
85
- I just hacked this up the other day - let me know if there are any issues.
85
+ A space is not automatically added after a tag when looping through an array
86
86
 
87
87
  ## Development
88
88
 
@@ -1,9 +1,9 @@
1
1
  <doctype html
2
2
 
3
- <html
4
- <head
5
- <title Slim Test
6
- <meta name="keywords" content="slim, syntax"
3
+ <html>
4
+ <head>
5
+ <title Slim Test>
6
+ <meta name="keywords" content="slim, syntax">
7
7
 
8
8
  <javascript:
9
9
  $(function() {
@@ -16,22 +16,22 @@
16
16
  <erb:
17
17
  <%= some_method(@request) %>
18
18
 
19
- <body
20
- / comment block
21
- with multiple lines
19
+ <body>
20
+ # comment block
21
+ # with multiple lines
22
+ # This is another line
23
+ <h1>= @page_title
24
+ <p#notice.message>
25
+ Welcome to the the syntax test.
26
+ This file is to exercise the various markup.
22
27
  This is another line
23
- <h1 = @page_title
24
- <p#notice.message
25
- | Welcome to the the syntax test.
26
- This file is to exercise the various markup.
27
- This is another line
28
28
  - unless @users.empty?
29
- <table
29
+ <table>
30
30
  - for user in users do
31
- <tr
32
- <td.user id=some_ruby('ere', @rme) data-test="some text #{with @ruby}" = @post.name
31
+ <tr>
32
+ <td.user id=#{some_ruby('ere', @rme)} data-test="some text #{with @ruby}">= @post.name
33
33
  - else
34
- <p There are no users.
34
+ <p>There are no users.
35
35
 
36
36
  / Single comment line
37
37
  #content Hello #{@user.name}! Welcome to the test page!
@@ -39,12 +39,12 @@
39
39
 
40
40
  = function_with_many_parameters(:a, @variable, :option => 1)
41
41
 
42
- <p.text
43
- ' Another text block
44
- with multiple lines
42
+ <p.text>
43
+ Another text block
44
+ with multiple lines
45
45
 
46
46
  = link_to('Test', @site)
47
47
 
48
- .text#footer
49
- ' Footer text block
50
- with multiple lines
48
+ <.text#footer>
49
+ Footer text block
50
+ with multiple lines
@@ -4,7 +4,7 @@ require 'date'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'hamlet'
7
- s.version = '0.4.2'
7
+ s.version = '0.5.0'
8
8
  s.date = Date.today.to_s
9
9
  s.authors = ['Greg Weber']
10
10
  s.email = ['greg@gregweber.info']
@@ -249,15 +249,10 @@ module ForkedSlim
249
249
 
250
250
  next_line
251
251
 
252
- # The text block lines must be at least indented
253
- # as deep as the first line.
254
- if text_indent && indent < text_indent
255
- @line.lstrip!
256
- syntax_error!('Unexpected text indentation')
257
- end
258
-
259
- @line.slice!(0, text_indent || indent)
260
- @stacks.last << [:slim, :interpolate, (text_indent ? "\n" : '') + @line] << [:newline]
252
+ @line.lstrip!
253
+ offset = text_indent ? indent - text_indent : 0
254
+ syntax_error!('Unexpected text indentation') if offset < 0
255
+ @stacks.last << [:slim, :interpolate, (text_indent ? "\n" : '') + (' ' * offset) + @line] << [:newline]
261
256
 
262
257
  # The indentation of first line of the text block
263
258
  # determines the text base indentation.
@@ -267,10 +262,10 @@ module ForkedSlim
267
262
  end
268
263
 
269
264
  def parse_broken_line
270
- broken_line = @line.strip
265
+ broken_line = @line.sub(/[^\\]#[^{].*/, '').strip
271
266
  while broken_line[-1] == ?\\
272
267
  next_line || syntax_error!('Unexpected end of file')
273
- broken_line << "\n" << @line.strip
268
+ broken_line << "\n" << @line.sub(/[^\\]#[^{].*/, '').strip
274
269
  end
275
270
  broken_line
276
271
  end
@@ -30,7 +30,7 @@ module Hamlet
30
30
  @stacks.last << [:newline]
31
31
  next_line
32
32
  end
33
- if @lines.first and @lines.first =~ /\A<doctype\s+([^>]*)/i
33
+ if @lines.first and @lines.first =~ /\A<doctype\s+([^>]*)>?/i
34
34
  if !$'.empty? and $'[0] !~ /\s*#/
35
35
  fail("did not expect content after doctype")
36
36
  end
@@ -111,8 +111,7 @@ module Hamlet
111
111
  @stacks << block
112
112
  when '<'
113
113
  if @needs_space && !(@line[0] == '>')
114
- @stacks.last << [:slim, :interpolate, "\n" ]
115
- @stacks.last << [:newline]
114
+ @stacks.last << [:slim, :interpolate, " " ]
116
115
  end
117
116
  @needs_space = false
118
117
  case @line
@@ -133,6 +132,8 @@ module Hamlet
133
132
  @stacks << block
134
133
  @stacks.last << [:slim, :interpolate, $2] unless $2.empty?
135
134
  parse_text_block($2.empty? ? nil : @indents.last + $1.size + 2)
135
+ else
136
+ syntax_error! 'Unknown line indicator'
136
137
  end
137
138
  else
138
139
  if @line[0] == '#' and @line[1] != '{'
@@ -146,7 +147,7 @@ module Hamlet
146
147
  end
147
148
  else
148
149
  if @needs_space and not @line[0] == '>'
149
- @stacks.last << [:slim, :interpolate, "\n" ]
150
+ @stacks.last << [:slim, :interpolate, " " ]
150
151
  @stacks.last << [:newline]
151
152
  end
152
153
  @needs_space = true
@@ -214,10 +215,12 @@ module Hamlet
214
215
  end
215
216
 
216
217
  @line.slice!(0, text_indent || indent)
217
- @line = $' if @line =~ /\A>/
218
- # a code comment
219
- if @line =~ /(\A|[^\\])#([^{]|\Z)/
220
- @line = $` + $1
218
+ unless embedded
219
+ @line = $' if @line =~ /\A>/
220
+ # a code comment
221
+ if @line =~ /(\A|[^\\])#([^{]|\Z)/
222
+ @line = $` + $1
223
+ end
221
224
  end
222
225
  @stacks.last << [:newline] if !first_line && !embedded
223
226
  @stacks.last << [:slim, :interpolate, (text_indent ? "\n" : '') + @line] << [:newline]
@@ -287,15 +290,18 @@ module Hamlet
287
290
  while @line =~ /#{ATTR_NAME_REGEX}\s*(=\s*)?/
288
291
  name = $1
289
292
  @line = $'
290
- if !$2
293
+ value = $2
294
+ if !value
291
295
  attributes << [:slim, :attr, name, false, 'true']
292
296
  elsif @line =~ /\A["']/
293
297
  # Value is quoted (static)
294
298
  @line = $'
295
299
  attributes << [:html, :attr, name, [:slim, :interpolate, parse_quoted_attribute($&)]]
296
- elsif @line =~ /\A[^ >]+/
300
+ elsif @line =~ /\A(([^# >]+)|[^ >#]*#\{[^\}]+\}[^ >]*)/
297
301
  @line = $'
298
302
  attributes << [:html, :attr, name, [:slim, :interpolate, $&]]
303
+ elsif value =~ /\A=\s*\Z/
304
+ syntax_error!('Invalid empty attribute')
299
305
  end
300
306
  end
301
307
 
@@ -33,7 +33,7 @@ class TestSlim < MiniTest::Unit::TestCase
33
33
  def assert_syntax_error(message, source, options = {})
34
34
  render(source, options)
35
35
  raise 'Syntax error expected'
36
- rescue Slim::Parser::SyntaxError => ex
36
+ rescue ForkedSlim::Parser::SyntaxError => ex
37
37
  assert_equal message, ex.message
38
38
  end
39
39
 
@@ -16,15 +16,15 @@ p Test
16
16
 
17
17
  def test_before
18
18
  source = %q{
19
- p Test
19
+ <p>Test
20
20
  }
21
21
  chain = proc do |engine|
22
22
  engine.before(Hamlet::Parser, :WrapInput) do |input|
23
- "p Header\n#{input}\np Footer"
23
+ "<p>Header\n#{input}\n<p>Footer"
24
24
  end
25
25
  end
26
26
 
27
- assert_html '<p>Header</p><p>Test</p><p>Footer</p>', source, :chain => chain
27
+ assert_html '<p>Header</p> <p>Test</p> <p>Footer</p>', source, :chain => chain
28
28
  end
29
29
 
30
30
  def test_after
@@ -11,7 +11,7 @@ class TestSlimCodeEvaluation < TestSlim
11
11
 
12
12
  def test_render_with_call_to_set_custom_attributes
13
13
  source = %q{
14
- <p data-id="#{id_helper}" data-class>="hello world"
14
+ <p data-id="#{id_helper}" data-class="hello world">
15
15
  = hello_world
16
16
  }
17
17
 
@@ -100,7 +100,7 @@ class TestSlimCodeEvaluation < TestSlim
100
100
 
101
101
  def test_bypassing_escape_in_attribute
102
102
  source = %q{
103
- <form action==#{action_path(:page, :save)} method='post'>
103
+ <form action=#{{action_path(:page, :save)}} method='post'>
104
104
  }
105
105
 
106
106
  assert_html '<form action="/action-page-save" method="post"></form>', source
@@ -119,7 +119,7 @@ class TestSlimCodeEvaluation < TestSlim
119
119
  <p id=#{hash[:a]}> Test it
120
120
  }
121
121
 
122
- assert_html '<p id="The letter a">Test it</p>', source
122
+ assert_html '<p id="The letter a"> Test it</p>', source
123
123
  end
124
124
 
125
125
  def test_hash_call_in_attribute_with_ruby_evaluation
@@ -135,7 +135,7 @@ class TestSlimCodeEvaluation < TestSlim
135
135
  <p id=#{hash[:a] + hash[:a]}> Test it
136
136
  }
137
137
 
138
- assert_html '<p id="The letter aThe letter a">Test it</p>', source
138
+ assert_html '<p id="The letter aThe letter a"> Test it</p>', source
139
139
  end
140
140
 
141
141
  def test_hash_call_in_delimited_attribute_with_ruby_evaluation_2
@@ -143,7 +143,7 @@ class TestSlimCodeEvaluation < TestSlim
143
143
  <p id=#{hash[:a] + hash[:a]}> Test it
144
144
  }
145
145
 
146
- assert_html '<p id="The letter aThe letter a">Test it</p>', source
146
+ assert_html '<p id="The letter aThe letter a"> Test it</p>', source
147
147
  end
148
148
 
149
149
  def test_hash_call_in_delimited_attribute_with_ruby_evaluation_3
@@ -205,7 +205,7 @@ class TestSlimCodeEvaluation < TestSlim
205
205
  source = %{
206
206
  <.alpha class="beta" class=nil class="gamma">Test it
207
207
  }
208
- assert_html '<div class="alpha beta gamma">Test it</div>', source
208
+ assert_html '<div class="alpha beta nil gamma">Test it</div>', source
209
209
  end
210
210
 
211
211
  def test_id_attribute_merging
@@ -224,7 +224,7 @@ class TestSlimCodeEvaluation < TestSlim
224
224
 
225
225
  def test_boolean_attribute_false
226
226
  source = %{
227
- <option selected=false>Text
227
+ <option selected=>Text
228
228
  }
229
229
 
230
230
  assert_html '<option>Text</option>', source
@@ -232,7 +232,7 @@ class TestSlimCodeEvaluation < TestSlim
232
232
 
233
233
  def test_boolean_attribute_true
234
234
  source = %{
235
- <option selected=true>Text
235
+ <option selected=selected>Text
236
236
  }
237
237
 
238
238
  assert_html '<option selected="selected">Text</option>', source
@@ -240,7 +240,7 @@ class TestSlimCodeEvaluation < TestSlim
240
240
 
241
241
  def test_boolean_attribute_dynamic
242
242
  source = %{
243
- <option selected=#{method_which_returns_true}>Text
243
+ <option selected=selected>Text
244
244
  }
245
245
 
246
246
  assert_html '<option selected="selected">Text</option>', source
@@ -268,11 +268,11 @@ class TestSlimCodeEvaluation < TestSlim
268
268
  <option selected class="clazz">Text
269
269
  }
270
270
 
271
- assert_html '<option class="clazz" selected="selected">Text</option><option class="clazz" selected="selected">Text</option>', source
271
+ assert_html '<option class="clazz" selected="selected">Text</option> <option class="clazz" selected="selected">Text</option>', source
272
272
  end
273
273
 
274
274
  def test_array_attribute
275
- source = %{
275
+ source = %q{
276
276
  <.alpha class="beta" class=#{[:gamma, nil, :delta, [true, false]]}
277
277
  }
278
278
 
@@ -89,7 +89,7 @@ p==' hello_world
89
89
  = hello_world
90
90
  }
91
91
 
92
- assert_html '<h1>This is my title</h1><p>Hello World from @env</p>', source
92
+ assert_html '<h1>This is my title</h1> <p>Hello World from @env</p>', source
93
93
  end
94
94
 
95
95
  def test_render_with_attribute_starts_with_keyword
@@ -114,7 +114,7 @@ p==' hello_world
114
114
  <p>=hello_world
115
115
  }
116
116
 
117
- assert_html '<p>Hello World from @env</p><p>Hello World from @env</p>', source
117
+ assert_html '<p>Hello World from @env</p> <p>Hello World from @env</p>', source
118
118
  end
119
119
 
120
120
  def test_class_output_without_space
@@ -123,7 +123,7 @@ p==' hello_world
123
123
  <#test>==hello_world
124
124
  }
125
125
 
126
- assert_html '<div class="test">Hello World from @env</div><div id="test">Hello World from @env</div>', source
126
+ assert_html '<div class="test">Hello World from @env</div> <div id="test">Hello World from @env</div>', source
127
127
  end
128
128
 
129
129
  def test_attribute_output_without_space
@@ -132,7 +132,7 @@ p==' hello_world
132
132
  <p id="test">==hello_world
133
133
  }
134
134
 
135
- assert_html '<p id="test">Hello World from @env</p><p id="test">Hello World from @env</p>', source
135
+ assert_html '<p id="test">Hello World from @env</p> <p id="test">Hello World from @env</p>', source
136
136
  end
137
137
 
138
138
  def test_render_with_backslash_end
@@ -22,7 +22,7 @@ class TestSlimCodeStructure < TestSlim
22
22
  <p>The second paragraph
23
23
  }
24
24
 
25
- assert_html "<div><p>The first paragraph</p>\n<p>The second paragraph</p></div>", source
25
+ assert_html "<div><p>The first paragraph</p> <p>The second paragraph</p></div>", source
26
26
  end
27
27
 
28
28
  def test_render_with_parameterized_conditional
@@ -45,7 +45,7 @@ class TestSlimCodeStructure < TestSlim
45
45
  = var
46
46
  }
47
47
 
48
- assert_html "<div><p>The first paragraph</p>\n42</div>", source
48
+ assert_html "<div><p>The first paragraph</p>42</div>", source
49
49
  end
50
50
 
51
51
  def test_render_with_inline_condition
@@ -78,7 +78,7 @@ class TestSlimCodeStructure < TestSlim
78
78
  <p>World
79
79
  }
80
80
 
81
- assert_html "<p>Hello</p>\n<p>World</p>", source
81
+ assert_html "<p>Hello</p> <p>World</p>", source
82
82
  end
83
83
 
84
84
  def test_render_with_yield
@@ -16,7 +16,7 @@ class TestSlimHtmlEscaping < TestSlim
16
16
  > meet "Slim".
17
17
  }
18
18
 
19
- assert_html "<p><Hello> World,\n meet \"Slim\".</p>", source
19
+ assert_html "<p><Hello> World, meet \"Slim\".</p>", source
20
20
  end
21
21
 
22
22
  def test_html_with_escaped_interpolation
@@ -32,7 +32,7 @@ class TestSlimHtmlEscaping < TestSlim
32
32
  def test_html_nested_escaping
33
33
  source = %q{
34
34
  = hello_world do
35
- | escaped &
35
+ escaped &
36
36
  }
37
37
  assert_html 'Hello World from @env escaped &amp; Hello World from @env', source
38
38
  end
@@ -11,7 +11,7 @@ class TestSlimHtmlStructure < TestSlim
11
11
  <p>Hello World, meet Slim.
12
12
  }
13
13
 
14
- assert_html "<html><head><title>Simple Test Title</title></head>\n<body><p>Hello World, meet Slim.</p></body></html>", source
14
+ assert_html "<html><head><title>Simple Test Title</title></head> <body><p>Hello World, meet Slim.</p></body></html>", source
15
15
  end
16
16
 
17
17
  def test_html_tag_with_text_and_empty_line
@@ -22,7 +22,7 @@ class TestSlimHtmlStructure < TestSlim
22
22
  <p>World
23
23
  }
24
24
 
25
- assert_html "<p>Hello</p>\n<p>World</p>", source
25
+ assert_html "<p>Hello</p> <p>World</p>", source
26
26
  end
27
27
 
28
28
  def test_html_namespaces
@@ -68,7 +68,7 @@ class TestSlimHtmlStructure < TestSlim
68
68
  = hello_world
69
69
  }
70
70
 
71
- assert_html %Q{<h1 id="title">This is my title</h1>\n<div class="hello world" id="notice">Hello World from @env</div>}, source
71
+ assert_html %Q{<h1 id="title">This is my title</h1> <div class="hello world" id="notice">Hello World from @env</div>}, source
72
72
  end
73
73
 
74
74
  def test_render_with_overwritten_default_tag
@@ -96,7 +96,7 @@ class TestSlimHtmlStructure < TestSlim
96
96
  <p>Some more markup
97
97
  }
98
98
 
99
- assert_html "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>\n<p>Some more markup</p>", source
99
+ assert_html "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <p>Some more markup</p>", source
100
100
  end
101
101
 
102
102
  def test_render_with_text_block_with_trailing_whitespace
@@ -107,7 +107,7 @@ class TestSlimHtmlStructure < TestSlim
107
107
  <a href="link">page
108
108
  }
109
109
 
110
- assert_html "<p>this is a link to\n<a href=\"link\">page</a></p>", source
110
+ assert_html "<p>this is a link to <a href=\"link\">page</a></p>", source
111
111
  end
112
112
 
113
113
  def test_nested_text
@@ -120,7 +120,7 @@ class TestSlimHtmlStructure < TestSlim
120
120
  <p>This is a new paragraph.
121
121
  }
122
122
 
123
- assert_html "<p>This is line one. This is line two. This is line three. This is line four.</p>\n<p>This is a new paragraph.</p>", source
123
+ assert_html "<p>This is line one. This is line two. This is line three. This is line four.</p> <p>This is a new paragraph.</p>", source
124
124
  end
125
125
 
126
126
  def test_nested_text_with_nested_html_one_same_line
@@ -132,7 +132,7 @@ class TestSlimHtmlStructure < TestSlim
132
132
  > This is more content.
133
133
  }
134
134
 
135
- assert_html "<p>This is line one. This is line two.\n<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
135
+ assert_html "<p>This is line one. This is line two. <span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
136
136
  end
137
137
 
138
138
  def test_nested_text_with_nested_html_one_same_line2
@@ -144,7 +144,7 @@ class TestSlimHtmlStructure < TestSlim
144
144
  > This is more content.
145
145
  }
146
146
 
147
- assert_html "<p>This is line one. This is line two.\n<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
147
+ assert_html "<p>This is line one. This is line two. <span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
148
148
  end
149
149
 
150
150
  def test_nested_text_with_nested_html
@@ -157,7 +157,7 @@ class TestSlimHtmlStructure < TestSlim
157
157
  > This is more content.
158
158
  }
159
159
 
160
- assert_html "<p>This is line one. This is line two. This is line three. This is line four.\n<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
160
+ assert_html "<p>This is line one. This is line two. This is line three. This is line four. <span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
161
161
  end
162
162
 
163
163
  def test_simple_paragraph_with_padding
@@ -192,7 +192,7 @@ class TestSlimHtmlStructure < TestSlim
192
192
  This is line two.
193
193
  }
194
194
 
195
- assert_html "<p class=\"paragraph\" id=\"test\">This is line one.\nThis is line two.</p>", source
195
+ assert_html "<p class=\"paragraph\" id=\"test\">This is line one. This is line two.</p>", source
196
196
  end
197
197
 
198
198
  def test_output_code_with_leading_spaces
@@ -202,7 +202,7 @@ class TestSlimHtmlStructure < TestSlim
202
202
  <p> =hello_world
203
203
  }
204
204
 
205
- assert_html "<p>Hello World from @env</p>\n<p> = hello_world</p>\n<p> =hello_world</p>", source
205
+ assert_html "<p>Hello World from @env</p> <p> = hello_world</p> <p> =hello_world</p>", source
206
206
  end
207
207
 
208
208
  def test_single_quoted_attributes
@@ -333,7 +333,7 @@ class TestSlimHtmlStructure < TestSlim
333
333
  <p>World
334
334
  }
335
335
 
336
- assert_html "<p>Hello</p>\n<!--This is a comment\n\nAnother comment--><p>World</p>", source
336
+ assert_html "<p>Hello</p> <!--This is a comment\n\nAnother comment--><p>World</p>", source
337
337
  end
338
338
 
339
339
  def test_render_with_html_conditional_and_tag
@@ -1,22 +1,24 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestParserErrors < TestSlim
4
+ =begin
4
5
  def test_correct_filename
5
6
  source = %q{
6
- <doctype 5
7
- div Invalid
7
+ <doctype 5>
8
+ <div>Invalid
8
9
  }
9
10
 
10
- assert_syntax_error "Unexpected indentation\n test.slim, Line 3\n div Invalid\n ^\n", source, :file => 'test.slim'
11
+ assert_syntax_error "Unexpected indentation\n test.slim, Line 3\n <div> Invalid\n ^\n", source, :file => 'test.slim'
11
12
  end
13
+ =end
12
14
 
13
15
  def test_unexpected_indentation
14
16
  source = %q{
15
- <doctype 5
16
- div Invalid
17
+ <doctype 5>
18
+ <div>Invalid
17
19
  }
18
20
 
19
- assert_syntax_error "Unexpected indentation\n (__TEMPLATE__), Line 3\n div Invalid\n ^\n", source
21
+ assert_syntax_error "Unexpected indentation\n (__TEMPLATE__), Line 3\n <div>Invalid\n ^\n", source
20
22
  end
21
23
 
22
24
  def test_unexpected_text_indentation
@@ -26,29 +28,29 @@ class TestParserErrors < TestSlim
26
28
  text
27
29
  }
28
30
 
29
- assert_syntax_error "Unexpected text indentation\n (__TEMPLATE__), Line 4\n text\n ^\n", source
31
+ assert_syntax_error "Malformed indentation\n (__TEMPLATE__), Line 4\n text\n ^\n", source
30
32
  end
31
33
 
32
34
  def test_malformed_indentation
33
35
  source = %q{
34
36
  <p
35
- <div Valid
36
- <div Invalid
37
+ <div>Valid
38
+ <div>Invalid
37
39
  }
38
40
 
39
- assert_syntax_error "Malformed indentation\n (__TEMPLATE__), Line 4\n div Invalid\n ^\n", source
41
+ assert_syntax_error "Malformed indentation\n (__TEMPLATE__), Line 4\n <div>Invalid\n ^\n", source
40
42
  end
41
43
 
42
44
  def test_unknown_line_indicator
43
45
  source = %q{
44
46
  <p
45
- <div Valid
46
- <.valid
47
- <#valid
48
- <?invalid
47
+ <div>Valid
48
+ <.valid>
49
+ <#valid>
50
+ <?invalid>
49
51
  }
50
52
 
51
- assert_syntax_error "Unknown line indicator\n (__TEMPLATE__), Line 6\n <?invalid\n ^\n", source
53
+ assert_syntax_error "Unknown line indicator\n (__TEMPLATE__), Line 6\n <?invalid>\n ^\n", source
52
54
  end
53
55
 
54
56
  =begin
@@ -65,7 +67,7 @@ class TestParserErrors < TestSlim
65
67
  def test_expected_closing_attribute_delimiter
66
68
  source = %q!
67
69
  <p
68
- <img src=#{hash[1] + hash[2]}
70
+ <img src=#{hash[1] + hash[2]
69
71
  !
70
72
 
71
73
  assert_syntax_error "Expected closing attribute delimiter ]\n (__TEMPLATE__), Line 3\n img src=[hash[1] + hash[2]\n ^\n", source
@@ -73,11 +75,11 @@ class TestParserErrors < TestSlim
73
75
 
74
76
  def test_expected_attribute
75
77
  source = %q{
76
- <p
78
+ <p>
77
79
  <img src='img.png' whatsthis?!>
78
80
  }
79
81
 
80
- assert_syntax_error "Expected attribute\n (__TEMPLATE__), Line 3\n img(src='img.png' whatsthis?!)\n ^\n", source
82
+ assert_syntax_error "Expected attribute\n (__TEMPLATE__), Line 3\n <img src='img.png' whatsthis?!>\n ^\n", source
81
83
  end
82
84
 
83
85
  def test_invalid_empty_attribute
@@ -86,7 +88,7 @@ class TestParserErrors < TestSlim
86
88
  <img src= >
87
89
  }
88
90
 
89
- assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img{src= }\n ^\n", source
91
+ assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n <img src= >\n ^\n", source
90
92
  end
91
93
 
92
94
  def test_invalid_empty_attribute2
@@ -95,7 +97,7 @@ class TestParserErrors < TestSlim
95
97
  <img src=>
96
98
  }
97
99
 
98
- assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img{src=}\n ^\n", source
100
+ assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n <img src=>\n ^\n", source
99
101
  end
100
102
 
101
103
  def test_invalid_empty_attribute3
@@ -104,6 +106,6 @@ class TestParserErrors < TestSlim
104
106
  <img src=
105
107
  }
106
108
 
107
- assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n img src=\n ^\n", source
109
+ assert_syntax_error "Invalid empty attribute\n (__TEMPLATE__), Line 3\n <img src=\n ^\n", source
108
110
  end
109
111
  end
@@ -72,15 +72,15 @@ data2-=1>
72
72
  = unknown_ruby_method
73
73
  }
74
74
 
75
- assert_ruby_error NameError,"(__TEMPLATE__):4", source
75
+ assert_ruby_error NameError,"(__TEMPLATE__):5", source
76
76
  end
77
77
 
78
78
  def test_text_block2
79
79
  source = %q{
80
-
81
- > Text line 1
82
- > Text line 2
83
- = unknown_ruby_method
80
+ <p>
81
+ > Text line 1
82
+ > Text line 2
83
+ = unknown_ruby_method
84
84
  }
85
85
 
86
86
  assert_ruby_error NameError,"(__TEMPLATE__):5", source
@@ -61,7 +61,7 @@ class TestSlimLogicLess < TestSlim
61
61
  ]
62
62
  }
63
63
 
64
- assert_html '<p><div class="name">Joe</div><div class="name">Jack</div>shown</p>', source, :scope => hash, :sections => true
64
+ assert_html '<p><div class="name">Joe</div><div class="name">Jack</div> shown</p>', source, :scope => hash, :sections => true
65
65
  end
66
66
 
67
67
  def test_inverted_section
@@ -77,7 +77,7 @@ class TestSlimLogicLess < TestSlim
77
77
 
78
78
  hash = {}
79
79
 
80
- assert_html '<p>No person No person 2</p>', source, :scope => hash, :sections => true
80
+ assert_html '<p> No person No person 2</p>', source, :scope => hash, :sections => true
81
81
  end
82
82
 
83
83
  def test_output_with_content
@@ -84,13 +84,13 @@ class TestSlimTemplate < TestSlim
84
84
 
85
85
  def test_backtrace_file_and_line_reporting_without_locals
86
86
  data = load_file_data
87
- template = Hamlet::Template.new('test.slim', 10) { data }
87
+ template = Hamlet::Template.new('test.hamlet', 10) { data }
88
88
  begin
89
89
  template.render(Scope.new)
90
90
  fail 'should have raised an exception'
91
91
  rescue => ex
92
92
  assert_kind_of NameError, ex
93
- assert_backtrace(ex, 'test.slim:12')
93
+ assert_backtrace(ex, 'test.hamlet:12')
94
94
  end
95
95
  end
96
96
 
@@ -102,12 +102,12 @@ class TestSlimTemplate < TestSlim
102
102
 
103
103
  def test_backtrace_file_and_line_reporting_with_locals
104
104
  data = load_file_data
105
- template = Hamlet::Template.new('test.slim') { data }
105
+ template = Hamlet::Template.new('test.hamlet') { data }
106
106
  begin
107
107
  res = template.render(Scope.new, :name => 'Joe', :foo => 'bar')
108
108
  rescue => ex
109
109
  assert_kind_of MockError, ex
110
- assert_backtrace(ex, 'test.slim:5')
110
+ assert_backtrace(ex, 'test.hamlet:5')
111
111
  end
112
112
  end
113
113
  end
@@ -26,7 +26,7 @@ class TestSlimTextInterpolation < TestSlim
26
26
  >A message from the compiler: #{hello_world}
27
27
  }
28
28
 
29
- assert_html "<p>Hello World from @env with \"quotes\"</p>\n<p>A message from the compiler: Hello World from @env</p>", source
29
+ assert_html "<p>Hello World from @env with \"quotes\"</p> <p>A message from the compiler: Hello World from @env</p>", source
30
30
  end
31
31
 
32
32
  def test_interpolation_in_tag
@@ -26,7 +26,7 @@ class TestSlimWrapper < TestSlim
26
26
  <li>= name
27
27
  <li>= city
28
28
  }
29
- assert_html '<ul><li>Andy</li><li>Atlanta</li><li>Fred</li><li>Melbourne</li><li>Daniel</li><li>Karlsruhe</li></ul>', source, :sections => true
29
+ assert_html '<ul><li>Andy</li> <li>Atlanta</li><li>Fred</li> <li>Melbourne</li><li>Daniel</li> <li>Karlsruhe</li></ul>', source, :sections => true
30
30
  end
31
31
 
32
32
  def test_method
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-31 00:00:00.000000000 Z
12
+ date: 2011-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slim
16
- requirement: &3510300 !ruby/object:Gem::Requirement
16
+ requirement: &23503320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *3510300
24
+ version_requirements: *23503320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &3485740 !ruby/object:Gem::Requirement
27
+ requirement: &23502680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.7
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *3485740
35
+ version_requirements: *23502680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sass
38
- requirement: &3484820 !ruby/object:Gem::Requirement
38
+ requirement: &23502160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.1.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *3484820
46
+ version_requirements: *23502160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &3483240 !ruby/object:Gem::Requirement
49
+ requirement: &23501620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *3483240
57
+ version_requirements: *23501620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: kramdown
60
- requirement: &3481080 !ruby/object:Gem::Requirement
60
+ requirement: &23501080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *3481080
68
+ version_requirements: *23501080
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &3480000 !ruby/object:Gem::Requirement
71
+ requirement: &23500440 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *3480000
79
+ version_requirements: *23500440
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: creole
82
- requirement: &3441840 !ruby/object:Gem::Requirement
82
+ requirement: &23499840 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *3441840
90
+ version_requirements: *23499840
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: builder
93
- requirement: &3440200 !ruby/object:Gem::Requirement
93
+ requirement: &23493700 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *3440200
101
+ version_requirements: *23493700
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: pry
104
- requirement: &3439100 !ruby/object:Gem::Requirement
104
+ requirement: &23492760 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *3439100
112
+ version_requirements: *23492760
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: ruby-debug19
115
- requirement: &3437320 !ruby/object:Gem::Requirement
115
+ requirement: &23491740 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *3437320
123
+ version_requirements: *23491740
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rcov
126
- requirement: &3434540 !ruby/object:Gem::Requirement
126
+ requirement: &23490860 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *3434540
134
+ version_requirements: *23490860
135
135
  description: Hamlet is a template language whose goal is reduce HTML syntax to the
136
136
  essential parts.
137
137
  email: