slim 0.7.0 → 0.7.1

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.
@@ -6,7 +6,7 @@ class TestSlimCodeEvaluation < TestSlim
6
6
  p id="#{id_helper}" class="hello world" = hello_world
7
7
  }
8
8
 
9
- assert_html '<p id="notice" class="hello world">Hello World from @env</p>', source
9
+ assert_html '<p class="hello world" id="notice">Hello World from @env</p>', source
10
10
  end
11
11
 
12
12
  def test_render_with_call_to_set_custom_attributes
@@ -15,7 +15,7 @@ p data-id="#{id_helper}" data-class="hello world"
15
15
  = hello_world
16
16
  }
17
17
 
18
- assert_html '<p data-id="notice" data-class="hello world">Hello World from @env</p>', source
18
+ assert_html '<p data-class="hello world" data-id="notice">Hello World from @env</p>', source
19
19
  end
20
20
 
21
21
  def test_render_with_call_to_set_attributes_and_call_to_set_content
@@ -23,7 +23,7 @@ p data-id="#{id_helper}" data-class="hello world"
23
23
  p id="#{id_helper}" class="hello world" = hello_world
24
24
  }
25
25
 
26
- assert_html '<p id="notice" class="hello world">Hello World from @env</p>', source
26
+ assert_html '<p class="hello world" id="notice">Hello World from @env</p>', source
27
27
  end
28
28
 
29
29
  def test_render_with_parameterized_call_to_set_attributes_and_call_to_set_content
@@ -31,7 +31,7 @@ p id="#{id_helper}" class="hello world" = hello_world
31
31
  p id="#{id_helper}" class="hello world" = hello_world("Hello Ruby!")
32
32
  }
33
33
 
34
- assert_html '<p id="notice" class="hello world">Hello Ruby!</p>', source
34
+ assert_html '<p class="hello world" id="notice">Hello Ruby!</p>', source
35
35
  end
36
36
 
37
37
  def test_render_with_spaced_parameterized_call_to_set_attributes_and_call_to_set_content
@@ -39,7 +39,7 @@ p id="#{id_helper}" class="hello world" = hello_world("Hello Ruby!")
39
39
  p id="#{id_helper}" class="hello world" = hello_world "Hello Ruby!"
40
40
  }
41
41
 
42
- assert_html '<p id="notice" class="hello world">Hello Ruby!</p>', source
42
+ assert_html '<p class="hello world" id="notice">Hello Ruby!</p>', source
43
43
  end
44
44
 
45
45
  def test_render_with_spaced_parameterized_call_to_set_attributes_and_call_to_set_content_2
@@ -47,7 +47,7 @@ p id="#{id_helper}" class="hello world" = hello_world "Hello Ruby!"
47
47
  p id="#{id_helper}" class="hello world" = hello_world "Hello Ruby!", :dummy => "value"
48
48
  }
49
49
 
50
- assert_html '<p id="notice" class="hello world">Hello Ruby!dummy value</p>', source
50
+ assert_html '<p class="hello world" id="notice">Hello Ruby!dummy value</p>', source
51
51
  end
52
52
 
53
53
  def test_hash_call_in_attribute
@@ -58,6 +58,14 @@ p id="#{hash[:a]}" Test it
58
58
  assert_html '<p id="The letter a">Test it</p>', source
59
59
  end
60
60
 
61
+ def test_instance_variable_in_attribute_without_quotes
62
+ source = %q{
63
+ p id=@var
64
+ }
65
+
66
+ assert_html '<p id="instance"></p>', source
67
+ end
68
+
61
69
  def test_method_call_in_attribute_without_quotes
62
70
  source = %q{
63
71
  form action=action_path(:page, :save) method='post'
@@ -79,7 +87,7 @@ form(action=action_path(:page, :save) method='post')
79
87
  form(method='post' action=action_path(:page, :save))
80
88
  }
81
89
 
82
- assert_html '<form method="post" action="&#47;action-page-save"></form>', source
90
+ assert_html '<form action="&#47;action-page-save" method="post"></form>', source
83
91
  end
84
92
 
85
93
  def test_hash_call_in_attribute_without_quotes
@@ -135,7 +143,7 @@ p(id=[hash[:a] + hash[:a]]) Test it
135
143
  p(id=[hash[:a] + hash[:a]] class=[hash[:a]]) Test it
136
144
  }
137
145
 
138
- assert_html '<p id="The letter aThe letter a" class="The letter a">Test it</p>', source
146
+ assert_html '<p class="The letter a" id="The letter aThe letter a">Test it</p>', source
139
147
  end
140
148
 
141
149
  def test_hash_call_in_delimited_attribute_with_ruby_evaluation_5
@@ -143,7 +151,7 @@ p(id=[hash[:a] + hash[:a]] class=[hash[:a]]) Test it
143
151
  p(id=hash[:a] class=[hash[:a]]) Test it
144
152
  }
145
153
 
146
- assert_html '<p id="The letter a" class="The letter a">Test it</p>', source
154
+ assert_html '<p class="The letter a" id="The letter a">Test it</p>', source
147
155
  end
148
156
 
149
157
  def test_computation_in_attribute
@@ -196,4 +204,18 @@ p id="#{(false ? 'notshown' : 'shown')}" = output_number
196
204
  }
197
205
  assert_html '<div class="alpha beta">Test it</div>', source
198
206
  end
207
+
208
+ def test_id_attribute_merging
209
+ source = %{
210
+ #alpha id="beta" Test it
211
+ }
212
+ assert_html '<div id="alpha_beta">Test it</div>', source, :id_delimiter => '_'
213
+ end
214
+
215
+ def test_id_attribute_merging2
216
+ source = %{
217
+ #alpha id="beta" Test it
218
+ }
219
+ assert_html '<div id="alpha-beta">Test it</div>', source, :id_delimiter => '-'
220
+ end
199
221
  end
@@ -7,7 +7,7 @@ p
7
7
  = hello_world
8
8
  }
9
9
 
10
- assert_html '<p>Hello World from @env</p>', source
10
+ assert_html '<p>Hello World from @env</p>', source #, :debug => true
11
11
  end
12
12
 
13
13
  def test_render_with_conditional_call
@@ -113,4 +113,12 @@ p = \
113
113
 
114
114
  assert_html '<p>Hello Ruby!</p>7', source
115
115
  end
116
+
117
+ def test_render_with_no_trailing_character
118
+ source = %q{
119
+ p
120
+ = hello_world}
121
+
122
+ assert_html '<p>Hello World from @env</p>', source
123
+ end
116
124
  end
@@ -13,19 +13,6 @@ div
13
13
  assert_html '<div><p>The second paragraph</p></div>', source
14
14
  end
15
15
 
16
- def test_render_with_conditional_and_end
17
- source = %q{
18
- div
19
- - if show_first?
20
- p The first paragraph
21
- - else
22
- p The second paragraph
23
- - end
24
- }
25
-
26
- assert_html '<div><p>The second paragraph</p></div>', source
27
- end
28
-
29
16
  def test_render_with_consecutive_conditionals
30
17
  source = %q{
31
18
  div
@@ -50,6 +37,18 @@ div
50
37
  assert_html '<div><p>The second paragraph</p></div>', source
51
38
  end
52
39
 
40
+ def test_render_with_conditional_and_following_nonconditonal
41
+ source = %q{
42
+ div
43
+ - if true
44
+ p The first paragraph
45
+ - var = 42
46
+ = var
47
+ }
48
+
49
+ assert_html '<div><p>The first paragraph</p>42</div>', source
50
+ end
51
+
53
52
  def test_render_with_inline_condition
54
53
  source = %q{
55
54
  p = hello_world if true
@@ -82,4 +81,15 @@ p World
82
81
 
83
82
  assert_html '<p>Hello</p><p>World</p>', source
84
83
  end
84
+
85
+ def test_render_with_yield
86
+ source = %q{
87
+ div
88
+ == yield :menu
89
+ }
90
+
91
+ assert_html '<div>This is the menu</div>', source do
92
+ 'This is the menu'
93
+ end
94
+ end
85
95
  end
@@ -38,7 +38,7 @@ h1#title This is my title
38
38
  = hello_world
39
39
  }
40
40
 
41
- assert_html '<h1 id="title">This is my title</h1><div id="notice" class="hello world">Hello World from @env</div>', source
41
+ assert_html '<h1 id="title">This is my title</h1><div class="hello world" id="notice">Hello World from @env</div>', source
42
42
  end
43
43
 
44
44
  def test_render_with_text_block
@@ -147,7 +147,7 @@ p#test class="paragraph" This is line one.
147
147
  This is line two.
148
148
  }
149
149
 
150
- assert_html '<p id="test" class="paragraph">This is line one.This is line two.</p>', source
150
+ assert_html '<p class="paragraph" id="test">This is line one.This is line two.</p>', source
151
151
  end
152
152
 
153
153
  def test_output_code_with_leading_spaces
@@ -173,7 +173,7 @@ p class='underscored_class_name' = output_number
173
173
  p id="dashed-id" class="underscored_class_name" = output_number
174
174
  }
175
175
 
176
- assert_html '<p id="dashed-id" class="underscored_class_name">1337</p>', source
176
+ assert_html '<p class="underscored_class_name" id="dashed-id">1337</p>', source
177
177
  end
178
178
 
179
179
  def test_nonstandard_shortcut_attributes
@@ -181,7 +181,7 @@ p id="dashed-id" class="underscored_class_name" = output_number
181
181
  p#dashed-id.underscored_class_name = output_number
182
182
  }
183
183
 
184
- assert_html '<p id="dashed-id" class="underscored_class_name">1337</p>', source
184
+ assert_html '<p class="underscored_class_name" id="dashed-id">1337</p>', source
185
185
  end
186
186
 
187
187
  def test_dashed_attributes
@@ -197,7 +197,7 @@ p data-info="Illudium Q-36" = output_number
197
197
  p#marvin.martian data-info="Illudium Q-36" = output_number
198
198
  }
199
199
 
200
- assert_html '<p id="marvin" class="martian" data-info="Illudium Q-36">1337</p>', source
200
+ assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
201
201
  end
202
202
 
203
203
  def test_parens_around_attributes
@@ -205,7 +205,7 @@ p#marvin.martian data-info="Illudium Q-36" = output_number
205
205
  p(id="marvin" class="martian" data-info="Illudium Q-36") = output_number
206
206
  }
207
207
 
208
- assert_html '<p id="marvin" class="martian" data-info="Illudium Q-36">1337</p>', source
208
+ assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
209
209
  end
210
210
 
211
211
  def test_square_brackets_around_attributes
@@ -213,7 +213,7 @@ p(id="marvin" class="martian" data-info="Illudium Q-36") = output_number
213
213
  p[id="marvin" class="martian" data-info="Illudium Q-36"] = output_number
214
214
  }
215
215
 
216
- assert_html '<p id="marvin" class="martian" data-info="Illudium Q-36">1337</p>', source
216
+ assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
217
217
  end
218
218
 
219
219
  def test_parens_around_attributes_with_equal_sign_snug_to_right_paren
@@ -221,6 +221,30 @@ p[id="marvin" class="martian" data-info="Illudium Q-36"] = output_number
221
221
  p(id="marvin" class="martian" data-info="Illudium Q-36")= output_number
222
222
  }
223
223
 
224
- assert_html '<p id="marvin" class="martian" data-info="Illudium Q-36">1337</p>', source
224
+ assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
225
+ end
226
+
227
+ def test_closed_tag
228
+ source = %q{
229
+ closed/
230
+ }
231
+
232
+ assert_html '<closed />', source, :format => :xhtml
233
+ end
234
+
235
+ def test_closed_tag_with_attributes
236
+ source = %q{
237
+ closed id="test" /
238
+ }
239
+
240
+ assert_html '<closed id="test" />', source, :format => :xhtml
241
+ end
242
+
243
+ def test_closed_tag_with_attributes_and_parens
244
+ source = %q{
245
+ closed(id="test")/
246
+ }
247
+
248
+ assert_html '<closed id="test" />', source, :format => :xhtml
225
249
  end
226
250
  end
@@ -57,10 +57,10 @@ p
57
57
  img(src="img.jpg" title={title}
58
58
  }
59
59
 
60
- assert_syntax_error "Expected closing attribute delimiter )\n (__TEMPLATE__), Line 3\n img(src=\"img.jpg\" title={title}\n ^\n ", source
60
+ assert_syntax_error "Expected closing delimiter )\n (__TEMPLATE__), Line 3\n img(src=\"img.jpg\" title={title}\n ^\n ", source
61
61
  end
62
62
 
63
- def test_expected_closing_delimiter
63
+ def test_expected_closing_attribute_delimiter
64
64
  source = %q{
65
65
  p
66
66
  img src=[hash[1] + hash[2]
@@ -113,4 +113,32 @@ p
113
113
  }
114
114
  assert_ruby_syntax_error "(__TEMPLATE__):5", source
115
115
  end
116
+
117
+ def test_invalid_embedded_engine
118
+ source = %q{
119
+ p
120
+ embed_unknown:
121
+ 1+1
122
+ }
123
+
124
+ assert_runtime_error 'Invalid embedded engine embed_unknown', source
125
+ end
126
+
127
+ def test_explicit_end
128
+ source = %q{
129
+ div
130
+ - if show_first?
131
+ p The first paragraph
132
+ - end
133
+ }
134
+
135
+ assert_runtime_error 'Explicit end statements are forbidden', source
136
+ end
137
+
138
+ def test_id_attribute_merging2
139
+ source = %{
140
+ #alpha id="beta" Test it
141
+ }
142
+ assert_runtime_error 'Multiple id attributes specified, but id concatenation disabled', source
143
+ end
116
144
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Stone
@@ -16,28 +16,13 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-25 00:00:00 -04:00
19
+ date: 2010-11-03 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
- - !ruby/object:Gem::Dependency
23
- name: escape_utils
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- segments:
31
- - 0
32
- - 1
33
- - 9
34
- version: 0.1.9
35
- type: :runtime
36
- version_requirements: *id001
37
22
  - !ruby/object:Gem::Dependency
38
23
  name: temple
39
24
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
41
26
  none: false
42
27
  requirements:
43
28
  - - ~>
@@ -45,14 +30,14 @@ dependencies:
45
30
  segments:
46
31
  - 0
47
32
  - 1
48
- - 3
49
- version: 0.1.3
33
+ - 4
34
+ version: 0.1.4
50
35
  type: :runtime
51
- version_requirements: *id002
36
+ version_requirements: *id001
52
37
  - !ruby/object:Gem::Dependency
53
38
  name: tilt
54
39
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
56
41
  none: false
57
42
  requirements:
58
43
  - - ~>
@@ -62,11 +47,11 @@ dependencies:
62
47
  - 1
63
48
  version: "1.1"
64
49
  type: :runtime
65
- version_requirements: *id003
50
+ version_requirements: *id002
66
51
  - !ruby/object:Gem::Dependency
67
52
  name: rake
68
53
  prerelease: false
69
- requirement: &id004 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
70
55
  none: false
71
56
  requirements:
72
57
  - - ">="
@@ -77,11 +62,11 @@ dependencies:
77
62
  - 7
78
63
  version: 0.8.7
79
64
  type: :development
80
- version_requirements: *id004
65
+ version_requirements: *id003
81
66
  - !ruby/object:Gem::Dependency
82
67
  name: haml
83
68
  prerelease: false
84
- requirement: &id005 !ruby/object:Gem::Requirement
69
+ requirement: &id004 !ruby/object:Gem::Requirement
85
70
  none: false
86
71
  requirements:
87
72
  - - ">="
@@ -90,11 +75,11 @@ dependencies:
90
75
  - 0
91
76
  version: "0"
92
77
  type: :development
93
- version_requirements: *id005
78
+ version_requirements: *id004
94
79
  - !ruby/object:Gem::Dependency
95
80
  name: erubis
96
81
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
82
+ requirement: &id005 !ruby/object:Gem::Requirement
98
83
  none: false
99
84
  requirements:
100
85
  - - ">="
@@ -103,11 +88,11 @@ dependencies:
103
88
  - 0
104
89
  version: "0"
105
90
  type: :development
106
- version_requirements: *id006
91
+ version_requirements: *id005
107
92
  - !ruby/object:Gem::Dependency
108
93
  name: minitest
109
94
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
95
+ requirement: &id006 !ruby/object:Gem::Requirement
111
96
  none: false
112
97
  requirements:
113
98
  - - ">="
@@ -116,11 +101,11 @@ dependencies:
116
101
  - 0
117
102
  version: "0"
118
103
  type: :development
119
- version_requirements: *id007
104
+ version_requirements: *id006
120
105
  - !ruby/object:Gem::Dependency
121
106
  name: rcov
122
107
  prerelease: false
123
- requirement: &id008 !ruby/object:Gem::Requirement
108
+ requirement: &id007 !ruby/object:Gem::Requirement
124
109
  none: false
125
110
  requirements:
126
111
  - - ">="
@@ -129,11 +114,11 @@ dependencies:
129
114
  - 0
130
115
  version: "0"
131
116
  type: :development
132
- version_requirements: *id008
117
+ version_requirements: *id007
133
118
  - !ruby/object:Gem::Dependency
134
119
  name: rdiscount
135
120
  prerelease: false
136
- requirement: &id009 !ruby/object:Gem::Requirement
121
+ requirement: &id008 !ruby/object:Gem::Requirement
137
122
  none: false
138
123
  requirements:
139
124
  - - ">="
@@ -142,11 +127,11 @@ dependencies:
142
127
  - 0
143
128
  version: "0"
144
129
  type: :development
145
- version_requirements: *id009
130
+ version_requirements: *id008
146
131
  - !ruby/object:Gem::Dependency
147
132
  name: liquid
148
133
  prerelease: false
149
- requirement: &id010 !ruby/object:Gem::Requirement
134
+ requirement: &id009 !ruby/object:Gem::Requirement
150
135
  none: false
151
136
  requirements:
152
137
  - - ">="
@@ -155,11 +140,11 @@ dependencies:
155
140
  - 0
156
141
  version: "0"
157
142
  type: :development
158
- version_requirements: *id010
143
+ version_requirements: *id009
159
144
  - !ruby/object:Gem::Dependency
160
145
  name: yard
161
146
  prerelease: false
162
- requirement: &id011 !ruby/object:Gem::Requirement
147
+ requirement: &id010 !ruby/object:Gem::Requirement
163
148
  none: false
164
149
  requirements:
165
150
  - - ">="
@@ -168,7 +153,7 @@ dependencies:
168
153
  - 0
169
154
  version: "0"
170
155
  type: :development
171
- version_requirements: *id011
156
+ version_requirements: *id010
172
157
  description: Slim is a template language whose goal is reduce the syntax to the essential parts without becoming cryptic.
173
158
  email:
174
159
  - andy@stonean.com
@@ -202,7 +187,6 @@ files:
202
187
  - lib/slim/end_inserter.rb
203
188
  - lib/slim/engine.rb
204
189
  - lib/slim/filter.rb
205
- - lib/slim/helpers.rb
206
190
  - lib/slim/parser.rb
207
191
  - lib/slim/rails.rb
208
192
  - lib/slim/template.rb
@@ -212,7 +196,6 @@ files:
212
196
  - test/slim/test_code_blocks.rb
213
197
  - test/slim/test_code_escaping.rb
214
198
  - test/slim/test_code_evaluation.rb
215
- - test/slim/test_code_helpers.rb
216
199
  - test/slim/test_code_output.rb
217
200
  - test/slim/test_code_structure.rb
218
201
  - test/slim/test_embedded_engines.rb