slim 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -3
- data/README.md +39 -24
- data/Rakefile +1 -1
- data/lib/slim.rb +1 -1
- data/lib/slim/compiler.rb +3 -2
- data/slim.gemspec +4 -4
- data/test/slim/test_engine.rb +20 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slim (0.6.0
|
4
|
+
slim (0.6.0)
|
5
5
|
escape_utils
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
erubis (2.6.6)
|
12
|
+
abstract (>= 1.0.0)
|
10
13
|
escape_utils (0.1.8)
|
11
14
|
gemcutter (0.6.1)
|
12
15
|
git (1.2.5)
|
@@ -16,7 +19,6 @@ GEM
|
|
16
19
|
git (>= 1.2.5)
|
17
20
|
rubyforge (>= 2.0.0)
|
18
21
|
json_pure (1.4.6)
|
19
|
-
mustache (0.11.2)
|
20
22
|
rake (0.8.7)
|
21
23
|
rubyforge (2.0.4)
|
22
24
|
json_pure (>= 1.1.7)
|
@@ -25,9 +27,9 @@ PLATFORMS
|
|
25
27
|
ruby
|
26
28
|
|
27
29
|
DEPENDENCIES
|
30
|
+
erubis
|
28
31
|
escape_utils
|
29
32
|
haml
|
30
33
|
jeweler
|
31
|
-
mustache
|
32
34
|
rake
|
33
35
|
slim!
|
data/README.md
CHANGED
@@ -151,6 +151,13 @@ __Please note that all line indicators must be followed by a space__
|
|
151
151
|
div class="content"
|
152
152
|
= show_content
|
153
153
|
|
154
|
+
### Wrap attributes with parens
|
155
|
+
|
156
|
+
# If parens make the syntax more readable for you
|
157
|
+
|
158
|
+
body
|
159
|
+
h1(id="tagline" class="small tagline") = page_tagline
|
160
|
+
|
154
161
|
### Set an attribute's value with a method
|
155
162
|
|
156
163
|
# Use standard Ruby interpolation.
|
@@ -222,31 +229,39 @@ __Please note that all line indicators must be followed by a space__
|
|
222
229
|
|
223
230
|
## Benchmarks
|
224
231
|
|
225
|
-
#
|
226
|
-
|
227
|
-
|
228
|
-
erb
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
232
|
+
# Ubuntu 10.4 + Ruby 1.9.2
|
233
|
+
|
234
|
+
Rehearsal --------------------------------------------------------
|
235
|
+
erb 0.580000 0.010000 0.590000 ( 0.611149)
|
236
|
+
erubis 0.480000 0.000000 0.480000 ( 0.506241)
|
237
|
+
fast erubis 0.480000 0.010000 0.490000 ( 0.499427)
|
238
|
+
slim 0.640000 0.000000 0.640000 ( 0.667160)
|
239
|
+
haml 4.140000 0.000000 4.140000 ( 4.221195)
|
240
|
+
haml ugly 3.960000 0.000000 3.960000 ( 4.018103)
|
241
|
+
erb (cached) 0.200000 0.000000 0.200000 ( 0.208529)
|
242
|
+
erubis (cached) 0.160000 0.000000 0.160000 ( 0.167134)
|
243
|
+
fast erubis (cached) 0.140000 0.000000 0.140000 ( 0.152149)
|
244
|
+
slim (cached) 0.150000 0.000000 0.150000 ( 0.159058)
|
245
|
+
haml (cached) 0.450000 0.010000 0.460000 ( 0.462814)
|
246
|
+
haml ugly (cached) 0.370000 0.000000 0.370000 ( 0.387312)
|
247
|
+
---------------------------------------------- total: 11.780000sec
|
248
|
+
|
249
|
+
user system total real
|
250
|
+
erb 0.560000 0.010000 0.570000 ( 0.574373)
|
251
|
+
erubis 0.480000 0.000000 0.480000 ( 0.501512)
|
252
|
+
fast erubis 0.470000 0.000000 0.470000 ( 0.481918)
|
253
|
+
slim 0.610000 0.000000 0.610000 ( 0.612794)
|
254
|
+
haml 3.930000 0.010000 3.940000 ( 3.939419)
|
255
|
+
haml ugly 3.790000 0.010000 3.800000 ( 3.798528)
|
256
|
+
erb (cached) 0.190000 0.000000 0.190000 ( 0.188593)
|
257
|
+
erubis (cached) 0.160000 0.000000 0.160000 ( 0.159869)
|
258
|
+
fast erubis (cached) 0.140000 0.000000 0.140000 ( 0.135476)
|
259
|
+
slim (cached) 0.150000 0.000000 0.150000 ( 0.153698)
|
260
|
+
haml (cached) 0.430000 0.000000 0.430000 ( 0.436980)
|
261
|
+
haml ugly (cached) 0.370000 0.000000 0.370000 ( 0.372770)
|
262
|
+
|
248
263
|
|
249
264
|
## Authors
|
250
265
|
|
251
266
|
* [Andrew Stone](http://github.com/stonean)
|
252
|
-
* [Fred Wu](http://github.com/fredwu)
|
267
|
+
* [Fred Wu](http://github.com/fredwu)
|
data/Rakefile
CHANGED
@@ -19,7 +19,7 @@ begin
|
|
19
19
|
gem.add_development_dependency 'rake'
|
20
20
|
gem.add_development_dependency 'jeweler'
|
21
21
|
gem.add_development_dependency 'haml'
|
22
|
-
gem.add_development_dependency '
|
22
|
+
gem.add_development_dependency 'erubis'
|
23
23
|
end
|
24
24
|
Jeweler::GemcutterTasks.new
|
25
25
|
rescue LoadError
|
data/lib/slim.rb
CHANGED
data/lib/slim/compiler.rb
CHANGED
@@ -10,7 +10,7 @@ module Slim
|
|
10
10
|
CONTROL_WORDS = %w{if unless do}
|
11
11
|
ELSE_CONTROL_WORDS = %w{else elsif}
|
12
12
|
|
13
|
-
REGEX_LINE_PARSER = /^(\s*)(!?`?\|?-?=?\/?\w*)((\S*[#.]\S+)?(?:\s*(?:\w|-)*="[^=]+")*)?(.*)/
|
13
|
+
REGEX_LINE_PARSER = /^(\s*)(!?`?\|?-?=?\/?\w*)\(?((\S*[#.]\S+)?(?:\s*(?:\w|-)*="[^=]+")*)?\)?(.*)/
|
14
14
|
|
15
15
|
REGEX_LINE_CONTAINS_OUTPUT_CODE = /^\s*=(.*)/
|
16
16
|
REGEX_LINE_CONTAINS_METHOD_DETECTED = /^((?:(?!#{CONTROL_WORDS * '\b|'}\b).)*)/
|
@@ -63,9 +63,10 @@ module Slim
|
|
63
63
|
else :markup
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
unless attrs.empty?
|
67
67
|
normalize_attributes!(attrs) if shortcut_attrs
|
68
68
|
attrs.gsub!('"', '\"')
|
69
|
+
attrs = " #{attrs}" unless attrs =~ /^\s/
|
69
70
|
end
|
70
71
|
|
71
72
|
unless indent > last_indent
|
data/slim.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{slim}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew Stone", "Fred Wu"]
|
@@ -54,20 +54,20 @@ Gem::Specification.new do |s|
|
|
54
54
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
55
55
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
56
56
|
s.add_development_dependency(%q<haml>, [">= 0"])
|
57
|
-
s.add_development_dependency(%q<
|
57
|
+
s.add_development_dependency(%q<erubis>, [">= 0"])
|
58
58
|
else
|
59
59
|
s.add_dependency(%q<escape_utils>, [">= 0"])
|
60
60
|
s.add_dependency(%q<rake>, [">= 0"])
|
61
61
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
62
62
|
s.add_dependency(%q<haml>, [">= 0"])
|
63
|
-
s.add_dependency(%q<
|
63
|
+
s.add_dependency(%q<erubis>, [">= 0"])
|
64
64
|
end
|
65
65
|
else
|
66
66
|
s.add_dependency(%q<escape_utils>, [">= 0"])
|
67
67
|
s.add_dependency(%q<rake>, [">= 0"])
|
68
68
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
69
69
|
s.add_dependency(%q<haml>, [">= 0"])
|
70
|
-
s.add_dependency(%q<
|
70
|
+
s.add_dependency(%q<erubis>, [">= 0"])
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/test/slim/test_engine.rb
CHANGED
@@ -435,4 +435,24 @@ HTML
|
|
435
435
|
|
436
436
|
assert_equal expected, Slim::Engine.new(string).render(@env)
|
437
437
|
end
|
438
|
+
|
439
|
+
def test_parens_around_attributes
|
440
|
+
string = <<HTML
|
441
|
+
p(id="marvin" class="martian" data-info="Illudium Q-36") = output_number
|
442
|
+
HTML
|
443
|
+
|
444
|
+
expected = %(<p id="marvin" class="martian" data-info="Illudium Q-36">1337</p>)
|
445
|
+
|
446
|
+
assert_equal expected, Slim::Engine.new(string).render(@env)
|
447
|
+
end
|
448
|
+
|
449
|
+
def test_parens_around_attributes_with_equal_sign_snug_to_right_paren
|
450
|
+
string = <<HTML
|
451
|
+
p(id="marvin" class="martian" data-info="Illudium Q-36")= output_number
|
452
|
+
HTML
|
453
|
+
|
454
|
+
expected = %(<p id="marvin" class="martian" data-info="Illudium Q-36">1337</p>)
|
455
|
+
|
456
|
+
assert_equal expected, Slim::Engine.new(string).render(@env)
|
457
|
+
end
|
438
458
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andrew Stone
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: *id004
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
74
|
+
name: erubis
|
75
75
|
requirement: &id005 !ruby/object:Gem::Requirement
|
76
76
|
none: false
|
77
77
|
requirements:
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
hash:
|
126
|
+
hash: -160104932492896005
|
127
127
|
segments:
|
128
128
|
- 0
|
129
129
|
version: "0"
|