slim 1.0.0 → 1.0.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.
- data/CHANGES +9 -1
- data/README.md +13 -2
- data/lib/slim/compiler.rb +1 -1
- data/lib/slim/interpolation.rb +10 -21
- data/lib/slim/parser.rb +62 -75
- data/lib/slim/version.rb +1 -1
- data/test/slim/test_code_evaluation.rb +8 -0
- data/test/slim/test_embedded_engines.rb +15 -1
- data/test/slim/test_html_structure.rb +13 -12
- data/test/slim/test_parser_errors.rb +0 -9
- metadata +24 -25
- data/test_ruby_errors.rb +0 -191
data/CHANGES
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
master
|
2
|
+
|
3
|
+
1.0.1
|
4
|
+
|
5
|
+
* Only delimiting brackets must be balanced in ruby attributes
|
6
|
+
e.g this is possible now `a href=(ruby_code "{")
|
7
|
+
* Skip empty lines in text block (#156)
|
8
|
+
|
9
|
+
1.0.0
|
2
10
|
|
3
11
|
* Fixed html attribute issue in sections mode (#127)
|
4
12
|
* Obsolete directive syntax removed
|
data/README.md
CHANGED
@@ -15,11 +15,11 @@ Slim uses [Temple](https://github.com/judofyr/temple) for parsing/compilation an
|
|
15
15
|
|
16
16
|
## Why?
|
17
17
|
|
18
|
-
Within the Rails community, _Erb_ and _Haml_ are without doubt the two most popular templating engines. However, _Erb_'s syntax is cumbersome and _Haml_'s
|
18
|
+
Within the Rails community, _Erb_ and _Haml_ are without doubt the two most popular templating engines. However, _Erb_'s syntax is cumbersome and _Haml_'s syntax can be quite cryptic to the uninitiated.
|
19
19
|
|
20
20
|
Slim was born to bring a minimalist syntax approach with speed. If people chose not to use Slim, it would not be because of speed.
|
21
21
|
|
22
|
-
___Yes, Slim is speedy!___ Benchmarks are provided at the end of this README file.
|
22
|
+
___Yes, Slim is speedy!___ Benchmarks are provided at the end of this README file. Don't trust the numbers? That's as it should be. Therefore we provide a benchmark rake task so you could test it yourself (`rake bench`).
|
23
23
|
|
24
24
|
## How?
|
25
25
|
|
@@ -152,6 +152,12 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
152
152
|
h1(id="logo") = page_logo
|
153
153
|
h2[id="tagline" class="small tagline"] = page_tagline
|
154
154
|
|
155
|
+
|
156
|
+
If you wrap the attributes, you can spread them across multiple lines:
|
157
|
+
|
158
|
+
h2[ id="tagline"
|
159
|
+
class="small tagline"] = page_tagline
|
160
|
+
|
155
161
|
### Add content to a tag
|
156
162
|
|
157
163
|
Either start on the same line as the tag
|
@@ -283,6 +289,11 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
283
289
|
|
284
290
|
## Benchmarks
|
285
291
|
|
292
|
+
*The benchmarks are only to demonstrate that Slim's speed should not
|
293
|
+
be a determining factor in your template choice. Even if we don't
|
294
|
+
agree, we'd prefer you to use any other reason for choosing another
|
295
|
+
template language.*
|
296
|
+
|
286
297
|
# Linux + Ruby 1.9.2, 1000 iterations
|
287
298
|
|
288
299
|
user system total real
|
data/lib/slim/compiler.rb
CHANGED
data/lib/slim/interpolation.rb
CHANGED
@@ -37,30 +37,19 @@ module Slim
|
|
37
37
|
protected
|
38
38
|
|
39
39
|
def parse_expression(string)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
string.slice!(0)
|
47
|
-
break
|
48
|
-
elsif string =~ Parser::DELIMITER_REGEX
|
49
|
-
# Delimiter found, push it on the stack
|
50
|
-
stack << Parser::DELIMITERS[$&]
|
51
|
-
code << string.slice!(0)
|
52
|
-
elsif string =~ Parser::CLOSE_DELIMITER_REGEX
|
53
|
-
# Closing delimiter found, pop it from the stack if everything is ok
|
54
|
-
raise "Text interpolation: Unexpected closing #{$&}" if stack.empty?
|
55
|
-
raise "Text interpolation: Expected closing #{stack.last}" if stack.last != $&
|
56
|
-
code << string.slice!(0)
|
57
|
-
stack.pop
|
58
|
-
else
|
59
|
-
code << string.slice!(0)
|
40
|
+
count, i = 1, 0
|
41
|
+
while i < string.size && count != 0
|
42
|
+
if string[i] == ?{
|
43
|
+
count += 1
|
44
|
+
elsif string[i] == ?}
|
45
|
+
count -= 1
|
60
46
|
end
|
47
|
+
i += 1
|
61
48
|
end
|
62
49
|
|
63
|
-
|
50
|
+
raise "Text interpolation: Expected closing }" if count != 0
|
51
|
+
|
52
|
+
return string[i..-1], string[0, i-1]
|
64
53
|
end
|
65
54
|
end
|
66
55
|
end
|
data/lib/slim/parser.rb
CHANGED
@@ -57,23 +57,23 @@ module Slim
|
|
57
57
|
result
|
58
58
|
end
|
59
59
|
|
60
|
+
private
|
61
|
+
|
60
62
|
DELIMITERS = {
|
61
63
|
'(' => ')',
|
62
64
|
'[' => ']',
|
63
65
|
'{' => '}',
|
64
66
|
}.freeze
|
65
|
-
DELIMITER_REGEX = /\A[\(\[\{]/
|
66
|
-
CLOSE_DELIMITER_REGEX = /\A[\)\]\}]/
|
67
|
-
|
68
|
-
private
|
69
67
|
|
70
|
-
ATTR_NAME_REGEX = '\A\s*(\w[:\w-]*)'
|
71
|
-
QUOTED_VALUE_REGEX = /\A("[^"]*"|'[^']*')/
|
72
68
|
ATTR_SHORTCUT = {
|
73
69
|
'#' => 'id',
|
74
70
|
'.' => 'class',
|
75
71
|
}.freeze
|
76
72
|
|
73
|
+
DELIMITER_REGEX = /\A[\(\[\{]/
|
74
|
+
ATTR_NAME_REGEX = '\A\s*(\w[:\w-]*)'
|
75
|
+
QUOTED_VALUE_REGEX = /\A("[^"]*"|'[^']*')/
|
76
|
+
|
77
77
|
if RUBY_VERSION > '1.9'
|
78
78
|
CLASS_ID_REGEX = /\A(#|\.)([\w\u00c0-\uFFFF][\w:\u00c0-\uFFFF-]*)/
|
79
79
|
else
|
@@ -124,7 +124,7 @@ module Slim
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def parse_line
|
127
|
-
if @line
|
127
|
+
if @line =~ /\A\s*\Z/
|
128
128
|
@stacks.last << [:newline]
|
129
129
|
return
|
130
130
|
end
|
@@ -178,8 +178,8 @@ module Slim
|
|
178
178
|
block = [:multi]
|
179
179
|
@stacks.last << [:html, :comment, block]
|
180
180
|
@stacks << block
|
181
|
-
@stacks.last << [:slim, :interpolate, $2]
|
182
|
-
parse_text_block($
|
181
|
+
@stacks.last << [:slim, :interpolate, $2] unless $2.empty?
|
182
|
+
parse_text_block($2.empty? ? nil : @indents.last + $1.size + 2)
|
183
183
|
elsif @line =~ %r{\A/\[\s*(.*?)\s*\]\s*\Z}
|
184
184
|
# HTML conditional comment
|
185
185
|
block = [:multi]
|
@@ -189,15 +189,11 @@ module Slim
|
|
189
189
|
# Slim comment
|
190
190
|
parse_comment_block
|
191
191
|
end
|
192
|
-
when /\A[\|']/
|
192
|
+
when /\A([\|'])( ?)(.*)\Z/
|
193
193
|
# Found a text block.
|
194
|
-
trailing_ws =
|
195
|
-
|
196
|
-
|
197
|
-
else
|
198
|
-
@stacks.last << [:slim, :interpolate, @line.sub(/\A( )/, '')]
|
199
|
-
parse_text_block($1 ? 2 : 1)
|
200
|
-
end
|
194
|
+
trailing_ws = $1 == "'"
|
195
|
+
@stacks.last << [:slim, :interpolate, $3] unless $3.empty?
|
196
|
+
parse_text_block($3.empty? ? nil : @indents.last + $2.size + 1)
|
201
197
|
@stacks.last << [:static, ' '] if trailing_ws
|
202
198
|
when /\A-/
|
203
199
|
# Found a code block.
|
@@ -235,37 +231,44 @@ module Slim
|
|
235
231
|
end
|
236
232
|
|
237
233
|
def parse_comment_block
|
238
|
-
|
234
|
+
while !@lines.empty? && (@lines.first =~ /\A\s*\Z/ || get_indent(@lines.first) > @indents.last)
|
239
235
|
next_line
|
240
236
|
@stacks.last << [:newline]
|
241
237
|
end
|
242
238
|
end
|
243
239
|
|
244
|
-
def parse_text_block(
|
245
|
-
|
246
|
-
|
240
|
+
def parse_text_block(text_indent = nil)
|
241
|
+
empty_lines = 0
|
247
242
|
until @lines.empty?
|
248
|
-
|
249
|
-
|
243
|
+
if @lines.first =~ /\A\s*\Z/
|
244
|
+
next_line
|
245
|
+
@stacks.last << [:newline]
|
246
|
+
empty_lines += 1 if text_indent
|
247
|
+
else
|
248
|
+
indent = get_indent(@lines.first)
|
249
|
+
break if indent <= @indents.last
|
250
250
|
|
251
|
-
|
251
|
+
if empty_lines > 0
|
252
|
+
@stacks.last << [:slim, :interpolate, "\n" * empty_lines]
|
253
|
+
empty_lines = 0
|
254
|
+
end
|
252
255
|
|
253
|
-
|
254
|
-
# determines the text base indentation.
|
255
|
-
newline = text_indent ? "\n" : ''
|
256
|
-
text_indent ||= indent
|
256
|
+
next_line
|
257
257
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
258
|
+
# The text block lines must be at least indented
|
259
|
+
# as deep as the first line.
|
260
|
+
if text_indent && indent < text_indent
|
261
|
+
@line.lstrip!
|
262
|
+
syntax_error!('Unexpected text indentation')
|
263
|
+
end
|
264
264
|
|
265
|
-
|
265
|
+
@line.slice!(0, text_indent || indent)
|
266
|
+
@stacks.last << [:newline] << [:slim, :interpolate, (text_indent ? "\n" : '') + @line]
|
266
267
|
|
267
|
-
|
268
|
-
|
268
|
+
# The indentation of first line of the text block
|
269
|
+
# determines the text base indentation.
|
270
|
+
text_indent ||= indent
|
271
|
+
end
|
269
272
|
end
|
270
273
|
end
|
271
274
|
|
@@ -279,8 +282,6 @@ module Slim
|
|
279
282
|
end
|
280
283
|
|
281
284
|
def parse_tag(tag)
|
282
|
-
size = @line.size
|
283
|
-
|
284
285
|
if tag == '#' || tag == '.'
|
285
286
|
tag = 'div'
|
286
287
|
else
|
@@ -305,19 +306,16 @@ module Slim
|
|
305
306
|
content = [:multi]
|
306
307
|
tag << content
|
307
308
|
@stacks << content
|
308
|
-
|
309
|
+
when /\A( ?)(.*)\Z/
|
309
310
|
# Text content
|
310
|
-
content = [:multi, [:slim, :interpolate,
|
311
|
+
content = [:multi, [:slim, :interpolate, $2]]
|
311
312
|
tag << content
|
312
313
|
@stacks << content
|
313
|
-
parse_text_block(size - @line.size +
|
314
|
+
parse_text_block(@orig_line.size - @line.size + $1.size)
|
314
315
|
end
|
315
316
|
end
|
316
317
|
|
317
318
|
def parse_attributes
|
318
|
-
# Now we'll have to find all the attributes. We'll store these in an
|
319
|
-
# nested array: [[name, value], [name2, value2]]. The value is a piece
|
320
|
-
# of Ruby code.
|
321
319
|
attributes = [:html, :attrs]
|
322
320
|
|
323
321
|
# Find any literal class/id attributes
|
@@ -378,53 +376,42 @@ module Slim
|
|
378
376
|
:column => orig_line.size)
|
379
377
|
end
|
380
378
|
|
381
|
-
|
379
|
+
attributes
|
382
380
|
end
|
383
381
|
|
384
|
-
def parse_ruby_attribute(
|
385
|
-
# Delimiter
|
386
|
-
|
382
|
+
def parse_ruby_attribute(outer_delimiter)
|
383
|
+
# Delimiter count
|
384
|
+
count, delimiter, close_delimiter = 0, nil, nil
|
387
385
|
|
388
386
|
# Attribute value buffer
|
389
387
|
value = ''
|
390
388
|
|
391
389
|
# Attribute ends with space or attribute delimiter
|
392
|
-
end_regex = /\A[\s#{Regexp.escape
|
393
|
-
|
394
|
-
until @line.empty?
|
395
|
-
if
|
396
|
-
|
397
|
-
|
398
|
-
|
390
|
+
end_regex = /\A[\s#{Regexp.escape outer_delimiter.to_s}]/
|
391
|
+
|
392
|
+
until @line.empty? || (count == 0 && @line =~ end_regex)
|
393
|
+
if count > 0
|
394
|
+
if @line[0] == delimiter[0]
|
395
|
+
count += 1
|
396
|
+
elsif @line[0] == close_delimiter[0]
|
397
|
+
count -= 1
|
398
|
+
end
|
399
399
|
elsif @line =~ DELIMITER_REGEX
|
400
|
-
|
401
|
-
|
402
|
-
value << @line.slice!(0)
|
403
|
-
elsif @line =~ CLOSE_DELIMITER_REGEX
|
404
|
-
# Closing delimiter found, pop it from the stack if everything is ok
|
405
|
-
syntax_error!("Unexpected closing #{$&}") if stack.empty?
|
406
|
-
syntax_error!("Expected closing #{stack.last}") if stack.last != $&
|
407
|
-
value << @line.slice!(0)
|
408
|
-
stack.pop
|
409
|
-
else
|
410
|
-
value << @line.slice!(0)
|
400
|
+
count = 1
|
401
|
+
delimiter, close_delimiter = $&, DELIMITERS[$&]
|
411
402
|
end
|
403
|
+
value << @line.slice!(0)
|
412
404
|
end
|
413
405
|
|
414
|
-
|
415
|
-
|
416
|
-
end
|
417
|
-
|
418
|
-
if value.empty?
|
419
|
-
syntax_error!('Invalid empty attribute')
|
420
|
-
end
|
406
|
+
syntax_error!("Expected closing attribute delimiter #{close_delimiter}") if count != 0
|
407
|
+
syntax_error!('Invalid empty attribute') if value.empty?
|
421
408
|
|
422
409
|
# Remove attribute wrapper which doesn't belong to the ruby code
|
423
410
|
# e.g id=[hash[:a] + hash[:b]]
|
424
411
|
value = value[1..-2] if value =~ DELIMITER_REGEX &&
|
425
412
|
DELIMITERS[$&] == value[-1, 1]
|
426
413
|
|
427
|
-
|
414
|
+
value
|
428
415
|
end
|
429
416
|
|
430
417
|
# Helper for raising exceptions
|
data/lib/slim/version.rb
CHANGED
@@ -74,6 +74,14 @@ form action=action_path(:page, :save) method='post'
|
|
74
74
|
assert_html '<form action="/action-page-save" method="post"></form>', source
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_ruby_attribute_with_unbalanced_delimiters
|
78
|
+
source = %q{
|
79
|
+
div crazy=action_path('[') id="crazy_delimiters"
|
80
|
+
}
|
81
|
+
|
82
|
+
assert_html '<div crazy="/action-[" id="crazy_delimiters"></div>', source
|
83
|
+
end
|
84
|
+
|
77
85
|
def test_method_call_in_delimited_attribute_without_quotes
|
78
86
|
source = %q{
|
79
87
|
form(action=action_path(:page, :save) method='post')
|
@@ -63,8 +63,22 @@ creole:
|
|
63
63
|
source = %q{
|
64
64
|
javascript:
|
65
65
|
$(function() {});
|
66
|
+
|
67
|
+
|
68
|
+
alert('hello')
|
69
|
+
p Hi
|
70
|
+
}
|
71
|
+
assert_html %{<script type="text/javascript">$(function() {});\n\n\nalert('hello')</script><p>Hi</p>}, source
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_render_with_javascript_including_variable
|
75
|
+
# Keep the trailing space behind "javascript: "!
|
76
|
+
source = %q{
|
77
|
+
- func = "alert('hello');"
|
78
|
+
javascript:
|
79
|
+
$(function() { #{func} });
|
66
80
|
}
|
67
|
-
assert_html
|
81
|
+
assert_html %q|<script type="text/javascript">$(function() { alert('hello'); });</script>|, source
|
68
82
|
end
|
69
83
|
|
70
84
|
def test_render_with_ruby
|
@@ -7,13 +7,24 @@ class TestSlimHtmlStructure < TestSlim
|
|
7
7
|
html
|
8
8
|
head
|
9
9
|
title Simple Test Title
|
10
|
-
body
|
10
|
+
body
|
11
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
|
15
15
|
end
|
16
16
|
|
17
|
+
def test_html_tag_with_text_and_empty_line
|
18
|
+
# Keep the trailing space behind "body "!
|
19
|
+
source = %q{
|
20
|
+
p Hello
|
21
|
+
|
22
|
+
p World
|
23
|
+
}
|
24
|
+
|
25
|
+
assert_html "<p>Hello</p><p>World</p>", source
|
26
|
+
end
|
27
|
+
|
17
28
|
def test_html_namespaces
|
18
29
|
source = %q{
|
19
30
|
html:body
|
@@ -312,22 +323,12 @@ closed(id="test")/
|
|
312
323
|
source = %q{
|
313
324
|
p Hello
|
314
325
|
/! This is a comment
|
315
|
-
p World
|
316
|
-
}
|
317
|
-
|
318
|
-
assert_html "<p>Hello</p><!--This is a comment--><p>World</p>", source
|
319
|
-
end
|
320
326
|
|
321
|
-
def test_render_with_html_comments_2
|
322
|
-
source = %q{
|
323
|
-
p Hello
|
324
|
-
/! This is a comment
|
325
327
|
Another comment
|
326
|
-
Last line of comment.
|
327
328
|
p World
|
328
329
|
}
|
329
330
|
|
330
|
-
assert_html "<p>Hello</p><!--This is a comment\n
|
331
|
+
assert_html "<p>Hello</p><!--This is a comment\n\nAnother comment--><p>World</p>", source
|
331
332
|
end
|
332
333
|
|
333
334
|
def test_render_with_html_conditional_and_tag
|
@@ -78,15 +78,6 @@ p
|
|
78
78
|
assert_syntax_error "Expected attribute\n (__TEMPLATE__), Line 3\n img(src='img.png' whatsthis?!)\n ^\n", source
|
79
79
|
end
|
80
80
|
|
81
|
-
def test_unexpected_closing
|
82
|
-
source = %q{
|
83
|
-
p
|
84
|
-
img src=(1+1)]
|
85
|
-
}
|
86
|
-
|
87
|
-
assert_syntax_error "Unexpected closing ]\n (__TEMPLATE__), Line 3\n img src=(1+1)]\n ^\n", source
|
88
|
-
end
|
89
|
-
|
90
81
|
def test_invalid_empty_attribute
|
91
82
|
source = %q{
|
92
83
|
p
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,12 +11,12 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-07
|
14
|
+
date: 2011-08-07 00:00:00.000000000 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: temple
|
19
|
-
requirement: &
|
19
|
+
requirement: &2153659280 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: 0.3.0
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *2153659280
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: tilt
|
30
|
-
requirement: &
|
30
|
+
requirement: &2153658760 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '1.2'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *2153658760
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake
|
41
|
-
requirement: &
|
41
|
+
requirement: &2153658280 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: 0.8.7
|
47
47
|
type: :development
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *2153658280
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: haml
|
52
|
-
requirement: &
|
52
|
+
requirement: &2153657800 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: 3.1.0
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *2153657800
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: sass
|
63
|
-
requirement: &
|
63
|
+
requirement: &2153657320 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ! '>='
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: 3.1.0
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *2153657320
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: minitest
|
74
|
-
requirement: &
|
74
|
+
requirement: &2153656840 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: '0'
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *2153656840
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rcov
|
85
|
-
requirement: &
|
85
|
+
requirement: &2153656360 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ! '>='
|
@@ -90,10 +90,10 @@ dependencies:
|
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *2153656360
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: rdiscount
|
96
|
-
requirement: &
|
96
|
+
requirement: &2153655880 !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
@@ -101,10 +101,10 @@ dependencies:
|
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
|
-
version_requirements: *
|
104
|
+
version_requirements: *2153655880
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: liquid
|
107
|
-
requirement: &
|
107
|
+
requirement: &2153655400 !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
110
110
|
- - ! '>='
|
@@ -112,10 +112,10 @@ dependencies:
|
|
112
112
|
version: '0'
|
113
113
|
type: :development
|
114
114
|
prerelease: false
|
115
|
-
version_requirements: *
|
115
|
+
version_requirements: *2153655400
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
117
|
name: yard
|
118
|
-
requirement: &
|
118
|
+
requirement: &2153654920 !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
121
121
|
- - ! '>='
|
@@ -123,10 +123,10 @@ dependencies:
|
|
123
123
|
version: '0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
|
-
version_requirements: *
|
126
|
+
version_requirements: *2153654920
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: creole
|
129
|
-
requirement: &
|
129
|
+
requirement: &2153654440 !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|
132
132
|
- - ! '>='
|
@@ -134,7 +134,7 @@ dependencies:
|
|
134
134
|
version: '0'
|
135
135
|
type: :development
|
136
136
|
prerelease: false
|
137
|
-
version_requirements: *
|
137
|
+
version_requirements: *2153654440
|
138
138
|
description: Slim is a template language whose goal is reduce the syntax to the essential
|
139
139
|
parts without becoming cryptic.
|
140
140
|
email:
|
@@ -235,7 +235,6 @@ files:
|
|
235
235
|
- test/slim/test_slim_template.rb
|
236
236
|
- test/slim/test_text_interpolation.rb
|
237
237
|
- test/slim/test_wrapper.rb
|
238
|
-
- test_ruby_errors.rb
|
239
238
|
has_rdoc: true
|
240
239
|
homepage: http://github.com/stonean/slim
|
241
240
|
licenses: []
|
data/test_ruby_errors.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestSlimRubyErrors < TestSlim
|
4
|
-
def test_broken_output_line
|
5
|
-
source = %q{
|
6
|
-
p = hello_world + \
|
7
|
-
hello_world + \
|
8
|
-
unknown_ruby_method
|
9
|
-
}
|
10
|
-
|
11
|
-
assert_ruby_error NameError, "test.slim:4", source, :file => 'test.slim'
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_broken_output_line2
|
15
|
-
source = %q{
|
16
|
-
p = hello_world + \
|
17
|
-
hello_world
|
18
|
-
p Hello
|
19
|
-
= unknown_ruby_method
|
20
|
-
}
|
21
|
-
|
22
|
-
assert_ruby_error NameError,"(__TEMPLATE__):5", source
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_output_block
|
26
|
-
source = %q{
|
27
|
-
p = hello_world "Hello Ruby" do
|
28
|
-
= unknown_ruby_method
|
29
|
-
}
|
30
|
-
|
31
|
-
assert_ruby_error NameError,"(__TEMPLATE__):3", source
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_output_block2
|
35
|
-
source = %q{
|
36
|
-
p = hello_world "Hello Ruby" do
|
37
|
-
= "Hello from block"
|
38
|
-
p Hello
|
39
|
-
= unknown_ruby_method
|
40
|
-
}
|
41
|
-
|
42
|
-
assert_ruby_error NameError, "(__TEMPLATE__):5", source
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_text_block
|
46
|
-
source = %q{
|
47
|
-
p Text line 1 Text line 2
|
48
|
-
= unknown_ruby_method
|
49
|
-
}
|
50
|
-
|
51
|
-
assert_ruby_error NameError,"(__TEMPLATE__):4", source
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_text_block2
|
55
|
-
source = %q{
|
56
|
-
|
|
57
|
-
Text line 1
|
58
|
-
Text line 2
|
59
|
-
= unknown_ruby_method
|
60
|
-
}
|
61
|
-
|
62
|
-
assert_ruby_error NameError,"(__TEMPLATE__):5", source
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_comment
|
66
|
-
source = %q{
|
67
|
-
/ Comment line 1
|
68
|
-
Comment line 2
|
69
|
-
= unknown_ruby_method
|
70
|
-
}
|
71
|
-
|
72
|
-
assert_ruby_error NameError,"(__TEMPLATE__):4", source
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_embedded_ruby
|
76
|
-
source = %q{
|
77
|
-
ruby:
|
78
|
-
a = 1
|
79
|
-
b = 2
|
80
|
-
= a + b
|
81
|
-
= unknown_ruby_method
|
82
|
-
}
|
83
|
-
|
84
|
-
assert_ruby_error NameError,"(__TEMPLATE__):6", source
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_embedded_markdown
|
88
|
-
source = %q{
|
89
|
-
markdown:
|
90
|
-
#Header
|
91
|
-
Hello from #{"Markdown!"}
|
92
|
-
"Second Line!"
|
93
|
-
= unknown_ruby_method
|
94
|
-
}
|
95
|
-
|
96
|
-
assert_ruby_error NameError,"(__TEMPLATE__):6", source
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_embedded_liquid
|
100
|
-
source = %q{
|
101
|
-
- text = 'before liquid block'
|
102
|
-
liquid:
|
103
|
-
First
|
104
|
-
{{text}}
|
105
|
-
Third
|
106
|
-
= unknown_ruby_method
|
107
|
-
}
|
108
|
-
|
109
|
-
assert_ruby_error NameError,"(__TEMPLATE__):7", source
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_embedded_javascript
|
113
|
-
source = %q{
|
114
|
-
javascript:
|
115
|
-
alert();
|
116
|
-
alert();
|
117
|
-
= unknown_ruby_method
|
118
|
-
}
|
119
|
-
|
120
|
-
assert_ruby_error NameError,"(__TEMPLATE__):5", source
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_invalid_nested_code
|
124
|
-
source = %q{
|
125
|
-
p
|
126
|
-
- test = 123
|
127
|
-
= "Hello from within a block! "
|
128
|
-
}
|
129
|
-
assert_ruby_syntax_error "(__TEMPLATE__):5", source
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_invalid_nested_output
|
133
|
-
source = %q{
|
134
|
-
p
|
135
|
-
= "Hello Ruby!"
|
136
|
-
= "Hello from within a block! "
|
137
|
-
}
|
138
|
-
assert_ruby_syntax_error "(__TEMPLATE__):5", source
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_invalid_embedded_engine
|
142
|
-
source = %q{
|
143
|
-
p
|
144
|
-
embed_unknown:
|
145
|
-
1+1
|
146
|
-
}
|
147
|
-
|
148
|
-
assert_runtime_error 'Embedded engine embed_unknown not found', source
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_explicit_end
|
152
|
-
source = %q{
|
153
|
-
div
|
154
|
-
- if show_first?
|
155
|
-
p The first paragraph
|
156
|
-
- end
|
157
|
-
}
|
158
|
-
|
159
|
-
assert_runtime_error 'Explicit end statements are forbidden', source
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_id_attribute_merging2
|
163
|
-
source = %{
|
164
|
-
#alpha id="beta" Test it
|
165
|
-
}
|
166
|
-
assert_runtime_error 'Multiple id attributes specified', source
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_multiline_attributes
|
170
|
-
source = %q{
|
171
|
-
p(id="id"
|
172
|
-
foo=1+1
|
173
|
-
class=unknown_ruby_method)
|
174
|
-
p
|
175
|
-
}
|
176
|
-
|
177
|
-
assert_ruby_error NameError,"(__TEMPLATE__):3", source
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
def test_multiline_ruby_attribute
|
182
|
-
source = %q{
|
183
|
-
p id=(1+
|
184
|
-
+2
|
185
|
-
+unknown_ruby_method)
|
186
|
-
p
|
187
|
-
}
|
188
|
-
|
189
|
-
assert_ruby_error NameError,"(__TEMPLATE__):4", source
|
190
|
-
end
|
191
|
-
end
|