slim 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.yardopts +2 -0
- data/CHANGES +147 -0
- data/Gemfile +16 -0
- data/LICENSE +21 -0
- data/README.md +31 -36
- data/benchmarks/run.rb +114 -0
- data/benchmarks/src/complex.erb +23 -0
- data/benchmarks/src/complex.haml +18 -0
- data/benchmarks/src/complex.slim +17 -0
- data/benchmarks/src/complex_view.rb +15 -0
- data/extra/slim-mode.el +409 -0
- data/extra/test.slim +49 -0
- data/lib/slim/command.rb +0 -6
- data/lib/slim/compiler.rb +40 -51
- data/lib/slim/embedded_engine.rb +69 -41
- data/lib/slim/end_inserter.rb +5 -3
- data/lib/slim/engine.rb +9 -11
- data/lib/slim/filter.rb +10 -13
- data/lib/slim/grammar.rb +19 -0
- data/lib/slim/interpolation.rb +7 -5
- data/lib/slim/parser.rb +48 -33
- data/lib/slim/sections.rb +22 -26
- data/lib/slim/template.rb +7 -7
- data/lib/slim/version.rb +3 -1
- data/lib/slim/wrapper.rb +1 -0
- data/slim.gemspec +34 -0
- data/test/helper.rb +5 -1
- data/test/slim/test_code_escaping.rb +3 -3
- data/test/slim/test_code_evaluation.rb +49 -2
- data/test/slim/test_embedded_engines.rb +3 -1
- data/test/slim/test_html_escaping.rb +8 -0
- data/test/slim/test_html_structure.rb +18 -0
- data/test/slim/test_pretty.rb +8 -3
- data/test/slim/test_ruby_errors.rb +27 -2
- metadata +38 -46
@@ -90,6 +90,14 @@ form(method='post' action=action_path(:page, :save))
|
|
90
90
|
assert_html '<form action="/action-page-save" method="post"></form>', source
|
91
91
|
end
|
92
92
|
|
93
|
+
def test_bypassing_escape_in_attribute
|
94
|
+
source = %q{
|
95
|
+
form action==action_path(:page, :save) method='post'
|
96
|
+
}
|
97
|
+
|
98
|
+
assert_html '<form action="/action-page-save" method="post"></form>', source
|
99
|
+
end
|
100
|
+
|
93
101
|
def test_hash_call_in_attribute_without_quotes
|
94
102
|
source = %q{
|
95
103
|
p id=hash[:a] Test it
|
@@ -185,17 +193,56 @@ p id="#{(false ? 'notshown' : 'shown')}" = output_number
|
|
185
193
|
assert_html '<div class="alpha beta">Test it</div>', source
|
186
194
|
end
|
187
195
|
|
196
|
+
def test_class_attribute_merging_with_nil
|
197
|
+
source = %{
|
198
|
+
.alpha class="beta" class=nil class="gamma" Test it
|
199
|
+
}
|
200
|
+
assert_html '<div class="alpha beta gamma">Test it</div>', source
|
201
|
+
end
|
202
|
+
|
188
203
|
def test_id_attribute_merging
|
189
204
|
source = %{
|
190
205
|
#alpha id="beta" Test it
|
191
206
|
}
|
192
|
-
assert_html '<div id="alpha_beta">Test it</div>', source, :
|
207
|
+
assert_html '<div id="alpha_beta">Test it</div>', source, :attr_delimiter => {'class' => ' ', 'id' => '_' }
|
193
208
|
end
|
194
209
|
|
195
210
|
def test_id_attribute_merging2
|
196
211
|
source = %{
|
197
212
|
#alpha id="beta" Test it
|
198
213
|
}
|
199
|
-
assert_html '<div id="alpha-beta">Test it</div>', source, :
|
214
|
+
assert_html '<div id="alpha-beta">Test it</div>', source, :attr_delimiter => {'class' => ' ', 'id' => '-' }
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_boolean_attribute_true
|
218
|
+
source = %{
|
219
|
+
option selected=1 Text
|
220
|
+
}
|
221
|
+
|
222
|
+
assert_html '<option selected="selected">Text</option>', source
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_boolean_attribute_false
|
226
|
+
source = %{
|
227
|
+
option selected=false Text
|
228
|
+
}
|
229
|
+
|
230
|
+
assert_html '<option>Text</option>', source
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_non_boolean_attribute
|
234
|
+
source = %{
|
235
|
+
.alpha class="beta" class=false
|
236
|
+
}
|
237
|
+
|
238
|
+
assert_html '<div class="alpha beta false"></div>', source
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_array_attribute
|
242
|
+
source = %{
|
243
|
+
.alpha class="beta" class=[:gamma, nil, :delta, [true, false]]
|
244
|
+
}
|
245
|
+
|
246
|
+
assert_html '<div class="alpha beta gamma delta true false"></div>', source
|
200
247
|
end
|
201
248
|
end
|
@@ -10,13 +10,15 @@ class TestSlimEmbeddedEngines < TestSlim
|
|
10
10
|
p
|
11
11
|
- text = 'haml'
|
12
12
|
haml:
|
13
|
+
- passed_from_haml = 'from haml'
|
13
14
|
%b Hello from #{text.upcase}!
|
14
15
|
Second Line!
|
15
16
|
- if true
|
16
17
|
= true
|
18
|
+
= passed_from_haml
|
17
19
|
}
|
18
20
|
|
19
|
-
assert_html "<p><b>Hello from HAML!</b>\nSecond Line!\ntrue\
|
21
|
+
assert_html "<p><b>Hello from HAML!</b>\nSecond Line!\ntrue\nfrom haml</p>", source
|
20
22
|
end
|
21
23
|
|
22
24
|
def test_render_with_erb
|
@@ -29,4 +29,12 @@ p class="#{x}" test #{content}
|
|
29
29
|
|
30
30
|
assert_html '<p class=""">test <x></p>', source
|
31
31
|
end
|
32
|
+
|
33
|
+
def test_html_nested_escaping
|
34
|
+
source = %q{
|
35
|
+
= hello_world do
|
36
|
+
| escaped &
|
37
|
+
}
|
38
|
+
assert_html 'Hello World from @env escaped & Hello World from @env', source
|
39
|
+
end
|
32
40
|
end
|
@@ -338,4 +338,22 @@ p World
|
|
338
338
|
|
339
339
|
assert_html "<p>Hello</p><!--This is a comment\n Another comment\nLast line of comment.--><p>World</p>", source
|
340
340
|
end
|
341
|
+
|
342
|
+
def test_render_with_html_conditional_and_tag
|
343
|
+
source = %q{
|
344
|
+
/[ if IE ]
|
345
|
+
p Get a better browser.
|
346
|
+
}
|
347
|
+
|
348
|
+
assert_html "<!--[if IE]><p>Get a better browser.</p><![endif]-->", source
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_render_with_html_conditional_and_method_output
|
352
|
+
source = %q{
|
353
|
+
/[ if IE ]
|
354
|
+
= message 'hello'
|
355
|
+
}
|
356
|
+
|
357
|
+
assert_html "<!--[if IE]>hello<![endif]-->", source
|
358
|
+
end
|
341
359
|
end
|
data/test/slim/test_pretty.rb
CHANGED
@@ -9,7 +9,7 @@ class TestSlimPretty < TestSlim
|
|
9
9
|
Slim::Engine.set_default_options :pretty => false
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def test_pretty
|
13
13
|
source = %q{
|
14
14
|
doctype 5
|
15
15
|
html
|
@@ -20,7 +20,9 @@ html
|
|
20
20
|
background-color: red
|
21
21
|
body
|
22
22
|
#container
|
23
|
-
p Hello
|
23
|
+
p Hello
|
24
|
+
World!
|
25
|
+
p= "dynamic text with\nnewline"
|
24
26
|
}
|
25
27
|
|
26
28
|
result = %q{<!DOCTYPE html>
|
@@ -35,7 +37,10 @@ html
|
|
35
37
|
</head>
|
36
38
|
<body>
|
37
39
|
<div id="container">
|
38
|
-
<p>Hello
|
40
|
+
<p>Hello
|
41
|
+
World!</p>
|
42
|
+
<p>dynamic text with
|
43
|
+
newline</p>
|
39
44
|
</div>
|
40
45
|
</body>
|
41
46
|
</html>}
|
@@ -82,7 +82,32 @@ ruby:
|
|
82
82
|
= unknown_ruby_method
|
83
83
|
}
|
84
84
|
|
85
|
-
assert_ruby_error NameError,"(__TEMPLATE__):
|
85
|
+
assert_ruby_error NameError,"(__TEMPLATE__):6", source
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_embedded_markdown
|
89
|
+
source = %q{
|
90
|
+
markdown:
|
91
|
+
#Header
|
92
|
+
Hello from #{"Markdown!"}
|
93
|
+
"Second Line!"
|
94
|
+
= unknown_ruby_method
|
95
|
+
}
|
96
|
+
|
97
|
+
assert_ruby_error NameError,"(__TEMPLATE__):6", source
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_embedded_liquid
|
101
|
+
source = %q{
|
102
|
+
- text = 'before liquid block'
|
103
|
+
liquid:
|
104
|
+
First
|
105
|
+
{{text}}
|
106
|
+
Third
|
107
|
+
= unknown_ruby_method
|
108
|
+
}
|
109
|
+
|
110
|
+
assert_ruby_error NameError,"(__TEMPLATE__):7", source
|
86
111
|
end
|
87
112
|
|
88
113
|
def test_embedded_javascript
|
@@ -139,6 +164,6 @@ div
|
|
139
164
|
source = %{
|
140
165
|
#alpha id="beta" Test it
|
141
166
|
}
|
142
|
-
assert_runtime_error 'Multiple id attributes specified
|
167
|
+
assert_runtime_error 'Multiple id attributes specified', source
|
143
168
|
end
|
144
169
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 9
|
8
|
-
- 2
|
9
|
-
version: 0.9.2
|
4
|
+
prerelease:
|
5
|
+
version: 0.9.3
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Andrew Stone
|
@@ -16,7 +12,7 @@ autorequire:
|
|
16
12
|
bindir: bin
|
17
13
|
cert_chain: []
|
18
14
|
|
19
|
-
date: 2011-
|
15
|
+
date: 2011-05-15 00:00:00 -04:00
|
20
16
|
default_executable:
|
21
17
|
dependencies:
|
22
18
|
- !ruby/object:Gem::Dependency
|
@@ -27,11 +23,7 @@ dependencies:
|
|
27
23
|
requirements:
|
28
24
|
- - ~>
|
29
25
|
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
- 0
|
32
|
-
- 2
|
33
|
-
- 0
|
34
|
-
version: 0.2.0
|
26
|
+
version: 0.3.0
|
35
27
|
type: :runtime
|
36
28
|
version_requirements: *id001
|
37
29
|
- !ruby/object:Gem::Dependency
|
@@ -42,9 +34,6 @@ dependencies:
|
|
42
34
|
requirements:
|
43
35
|
- - ~>
|
44
36
|
- !ruby/object:Gem::Version
|
45
|
-
segments:
|
46
|
-
- 1
|
47
|
-
- 2
|
48
37
|
version: "1.2"
|
49
38
|
type: :runtime
|
50
39
|
version_requirements: *id002
|
@@ -56,10 +45,6 @@ dependencies:
|
|
56
45
|
requirements:
|
57
46
|
- - ">="
|
58
47
|
- !ruby/object:Gem::Version
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
- 8
|
62
|
-
- 7
|
63
48
|
version: 0.8.7
|
64
49
|
type: :development
|
65
50
|
version_requirements: *id003
|
@@ -71,89 +56,86 @@ dependencies:
|
|
71
56
|
requirements:
|
72
57
|
- - ">="
|
73
58
|
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
- 0
|
76
|
-
version: "0"
|
59
|
+
version: 3.1.0
|
77
60
|
type: :development
|
78
61
|
version_requirements: *id004
|
79
62
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
63
|
+
name: sass
|
81
64
|
prerelease: false
|
82
65
|
requirement: &id005 !ruby/object:Gem::Requirement
|
83
66
|
none: false
|
84
67
|
requirements:
|
85
68
|
- - ">="
|
86
69
|
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
- 0
|
89
|
-
version: "0"
|
70
|
+
version: 3.1.0
|
90
71
|
type: :development
|
91
72
|
version_requirements: *id005
|
92
73
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
74
|
+
name: minitest
|
94
75
|
prerelease: false
|
95
76
|
requirement: &id006 !ruby/object:Gem::Requirement
|
96
77
|
none: false
|
97
78
|
requirements:
|
98
79
|
- - ">="
|
99
80
|
- !ruby/object:Gem::Version
|
100
|
-
segments:
|
101
|
-
- 0
|
102
81
|
version: "0"
|
103
82
|
type: :development
|
104
83
|
version_requirements: *id006
|
105
84
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
85
|
+
name: rcov
|
107
86
|
prerelease: false
|
108
87
|
requirement: &id007 !ruby/object:Gem::Requirement
|
109
88
|
none: false
|
110
89
|
requirements:
|
111
90
|
- - ">="
|
112
91
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
92
|
version: "0"
|
116
93
|
type: :development
|
117
94
|
version_requirements: *id007
|
118
95
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
96
|
+
name: rdiscount
|
120
97
|
prerelease: false
|
121
98
|
requirement: &id008 !ruby/object:Gem::Requirement
|
122
99
|
none: false
|
123
100
|
requirements:
|
124
101
|
- - ">="
|
125
102
|
- !ruby/object:Gem::Version
|
126
|
-
segments:
|
127
|
-
- 0
|
128
103
|
version: "0"
|
129
104
|
type: :development
|
130
105
|
version_requirements: *id008
|
131
106
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
107
|
+
name: liquid
|
133
108
|
prerelease: false
|
134
109
|
requirement: &id009 !ruby/object:Gem::Requirement
|
135
110
|
none: false
|
136
111
|
requirements:
|
137
112
|
- - ">="
|
138
113
|
- !ruby/object:Gem::Version
|
139
|
-
segments:
|
140
|
-
- 0
|
141
114
|
version: "0"
|
142
115
|
type: :development
|
143
116
|
version_requirements: *id009
|
144
117
|
- !ruby/object:Gem::Dependency
|
145
|
-
name:
|
118
|
+
name: yard
|
146
119
|
prerelease: false
|
147
120
|
requirement: &id010 !ruby/object:Gem::Requirement
|
148
121
|
none: false
|
149
122
|
requirements:
|
150
123
|
- - ">="
|
151
124
|
- !ruby/object:Gem::Version
|
152
|
-
segments:
|
153
|
-
- 0
|
154
125
|
version: "0"
|
155
126
|
type: :development
|
156
127
|
version_requirements: *id010
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
name: creole
|
130
|
+
prerelease: false
|
131
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: "0"
|
137
|
+
type: :development
|
138
|
+
version_requirements: *id011
|
157
139
|
description: Slim is a template language whose goal is reduce the syntax to the essential parts without becoming cryptic.
|
158
140
|
email:
|
159
141
|
- andy@stonean.com
|
@@ -167,9 +149,21 @@ extra_rdoc_files:
|
|
167
149
|
- README.md
|
168
150
|
files:
|
169
151
|
- .gemtest
|
152
|
+
- .gitignore
|
153
|
+
- .yardopts
|
154
|
+
- CHANGES
|
155
|
+
- Gemfile
|
156
|
+
- LICENSE
|
170
157
|
- README.md
|
171
158
|
- Rakefile
|
159
|
+
- benchmarks/run.rb
|
160
|
+
- benchmarks/src/complex.erb
|
161
|
+
- benchmarks/src/complex.haml
|
162
|
+
- benchmarks/src/complex.slim
|
163
|
+
- benchmarks/src/complex_view.rb
|
172
164
|
- bin/slimrb
|
165
|
+
- extra/slim-mode.el
|
166
|
+
- extra/test.slim
|
173
167
|
- lib/slim.rb
|
174
168
|
- lib/slim/command.rb
|
175
169
|
- lib/slim/compiler.rb
|
@@ -177,6 +171,7 @@ files:
|
|
177
171
|
- lib/slim/end_inserter.rb
|
178
172
|
- lib/slim/engine.rb
|
179
173
|
- lib/slim/filter.rb
|
174
|
+
- lib/slim/grammar.rb
|
180
175
|
- lib/slim/interpolation.rb
|
181
176
|
- lib/slim/parser.rb
|
182
177
|
- lib/slim/rails.rb
|
@@ -184,6 +179,7 @@ files:
|
|
184
179
|
- lib/slim/template.rb
|
185
180
|
- lib/slim/version.rb
|
186
181
|
- lib/slim/wrapper.rb
|
182
|
+
- slim.gemspec
|
187
183
|
- test/helper.rb
|
188
184
|
- test/integration/rails/dummy/Rakefile
|
189
185
|
- test/integration/rails/dummy/app/controllers/application_controller.rb
|
@@ -255,21 +251,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
255
251
|
requirements:
|
256
252
|
- - ">="
|
257
253
|
- !ruby/object:Gem::Version
|
258
|
-
segments:
|
259
|
-
- 0
|
260
254
|
version: "0"
|
261
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
256
|
none: false
|
263
257
|
requirements:
|
264
258
|
- - ">="
|
265
259
|
- !ruby/object:Gem::Version
|
266
|
-
segments:
|
267
|
-
- 0
|
268
260
|
version: "0"
|
269
261
|
requirements: []
|
270
262
|
|
271
263
|
rubyforge_project: slim
|
272
|
-
rubygems_version: 1.
|
264
|
+
rubygems_version: 1.6.2
|
273
265
|
signing_key:
|
274
266
|
specification_version: 3
|
275
267
|
summary: Slim is a template language.
|