slim 4.1.0 → 5.2.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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +107 -0
- data/.yardopts +1 -1
- data/CHANGES +44 -8
- data/Gemfile +18 -45
- data/LICENSE +1 -1
- data/README.jp.md +28 -41
- data/README.md +66 -43
- data/Rakefile +2 -9
- data/doc/jp/translator.md +1 -1
- data/doc/logic_less.md +1 -1
- data/doc/translator.md +1 -1
- data/lib/slim/code_attributes.rb +2 -1
- data/lib/slim/command.rb +2 -8
- data/lib/slim/controls.rb +1 -0
- data/lib/slim/do_inserter.rb +4 -3
- data/lib/slim/embedded.rb +17 -17
- data/lib/slim/end_inserter.rb +3 -2
- data/lib/slim/engine.rb +3 -0
- data/lib/slim/erb_converter.rb +1 -0
- data/lib/slim/filter.rb +1 -0
- data/lib/slim/grammar.rb +1 -0
- data/lib/slim/include.rb +1 -0
- data/lib/slim/interpolation.rb +1 -0
- data/lib/slim/logic_less/context.rb +6 -7
- data/lib/slim/logic_less/filter.rb +1 -0
- data/lib/slim/logic_less.rb +1 -0
- data/lib/slim/parser.rb +26 -39
- data/lib/slim/railtie.rb +19 -0
- data/lib/slim/smart/escaper.rb +1 -1
- data/lib/slim/smart/filter.rb +3 -2
- data/lib/slim/smart/parser.rb +4 -3
- data/lib/slim/smart.rb +1 -0
- data/lib/slim/splat/builder.rb +16 -8
- data/lib/slim/splat/filter.rb +6 -4
- data/lib/slim/template.rb +1 -14
- data/lib/slim/translator.rb +4 -3
- data/lib/slim/version.rb +2 -1
- data/lib/slim.rb +2 -0
- data/slim.gemspec +14 -5
- data/test/core/helper.rb +3 -11
- data/test/core/test_code_evaluation.rb +1 -0
- data/test/core/test_code_structure.rb +17 -0
- data/test/core/test_commands.rb +19 -22
- data/test/core/test_embedded_engines.rb +18 -14
- data/test/core/test_encoding.rb +2 -2
- data/test/core/test_erb_converter.rb +4 -6
- data/test/core/test_html_attributes.rb +8 -0
- data/test/core/test_html_structure.rb +54 -0
- data/test/core/test_pretty.rb +4 -7
- data/test/core/test_ruby_errors.rb +19 -0
- data/test/literate/TESTS.md +72 -22
- data/test/literate/helper.rb +1 -1
- data/test/literate/run.rb +3 -3
- data/test/logic_less/test_logic_less.rb +15 -0
- data/test/rails/app/controllers/slim_controller.rb +7 -1
- data/test/rails/app/views/layouts/application.html+testvariant.slim +10 -0
- data/test/rails/app/views/slim/attributes.html.slim +3 -0
- data/test/rails/app/views/slim/splat_with_delimiter.slim +1 -0
- data/test/rails/config/application.rb +1 -18
- data/test/rails/test/test_slim.rb +24 -12
- data/test/sinatra/helper.rb +0 -2
- metadata +27 -37
- data/.travis.yml +0 -38
- data/benchmarks/context.rb +0 -11
- data/benchmarks/profile-parser.rb +0 -10
- data/benchmarks/profile-render.rb +0 -12
- data/benchmarks/run-benchmarks.rb +0 -120
- data/benchmarks/run-diffbench.rb +0 -21
- data/benchmarks/view.erb +0 -25
- data/benchmarks/view.haml +0 -20
- data/benchmarks/view.slim +0 -19
- data/test/rails/config/initializers/secret_token.rb +0 -7
@@ -9,6 +9,14 @@ class TestSlim < ActionDispatch::IntegrationTest
|
|
9
9
|
assert_html "<h1>Hello Slim!</h1>"
|
10
10
|
end
|
11
11
|
|
12
|
+
test "variant" do
|
13
|
+
get "/slim/variant"
|
14
|
+
assert_response :success
|
15
|
+
assert_template "slim/normal"
|
16
|
+
assert_template "layouts/application"
|
17
|
+
assert_equal @response.body, "<!DOCTYPE html><html><head><title>Variant</title></head><body><div class=\"content\"><h1>Hello Slim!</h1></div></body></html>"
|
18
|
+
end
|
19
|
+
|
12
20
|
test "xml view" do
|
13
21
|
get "/slim/xml"
|
14
22
|
assert_response :success
|
@@ -46,18 +54,12 @@ class TestSlim < ActionDispatch::IntegrationTest
|
|
46
54
|
assert_html "<h1>Hello Slim!</h1><p>With a partial!</p>"
|
47
55
|
end
|
48
56
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
test "streaming" do
|
56
|
-
get "/slim/streaming"
|
57
|
-
output = "2f\r\n<!DOCTYPE html><html><head><title>Dummy</title>\r\nd\r\n</head><body>\r\n17\r\nHeading set from a view\r\n15\r\n<div class=\"content\">\r\n53\r\n<p>Page content</p><h1><p>Hello Streaming!</p></h1><h2><p>Hello Streaming!</p></h2>\r\n14\r\n</div></body></html>\r\n0\r\n\r\n"
|
58
|
-
assert_equal output, @response.body
|
59
|
-
end
|
60
|
-
end
|
57
|
+
# TODO Reenable streaming test
|
58
|
+
# test "streaming" do
|
59
|
+
# get "/slim/streaming"
|
60
|
+
# output = "2f\r\n<!DOCTYPE html><html><head><title>Dummy</title>\r\nd\r\n</head><body>\r\n17\r\nHeading set from a view\r\n15\r\n<div class=\"content\">\r\n53\r\n<p>Page content</p><h1><p>Hello Streaming!</p></h1><h2><p>Hello Streaming!</p></h2>\r\n14\r\n</div></body></html>\r\n0\r\n\r\n"
|
61
|
+
# assert_equal output, @response.body
|
62
|
+
# end
|
61
63
|
|
62
64
|
test "render integers" do
|
63
65
|
get "/slim/integers"
|
@@ -83,8 +85,18 @@ class TestSlim < ActionDispatch::IntegrationTest
|
|
83
85
|
assert_xpath '//input[@id="entry_name" and @name="entry[name]" and @type="text"]'
|
84
86
|
end
|
85
87
|
|
88
|
+
test "attributes" do
|
89
|
+
get "/slim/attributes"
|
90
|
+
assert_html "<div class=\"static a-b\"></div>"
|
91
|
+
end
|
92
|
+
|
86
93
|
test "splat" do
|
87
94
|
get "/slim/splat"
|
88
95
|
assert_html "<div id=\"splat\"><splat>Hello</splat></div>"
|
89
96
|
end
|
97
|
+
|
98
|
+
test "splat with delimiter" do
|
99
|
+
get "/slim/splat_with_delimiter"
|
100
|
+
assert_html "<div class=\"cute nice\">Hello</div>"
|
101
|
+
end
|
90
102
|
end
|
data/test/sinatra/helper.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Mendler
|
8
8
|
- Andrew Stone
|
9
9
|
- Fred Wu
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-01-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: temple
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.7.6
|
22
|
-
- - "<"
|
19
|
+
- - "~>"
|
23
20
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
21
|
+
version: 0.10.0
|
25
22
|
type: :runtime
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
requirements:
|
29
|
-
- - "
|
26
|
+
- - "~>"
|
30
27
|
- !ruby/object:Gem::Version
|
31
|
-
version: 0.
|
32
|
-
- - "<"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0.9'
|
28
|
+
version: 0.10.0
|
35
29
|
- !ruby/object:Gem::Dependency
|
36
30
|
name: tilt
|
37
31
|
requirement: !ruby/object:Gem::Requirement
|
38
32
|
requirements:
|
39
33
|
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
version: 2.0
|
42
|
-
- - "<"
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '2.1'
|
35
|
+
version: 2.1.0
|
45
36
|
type: :runtime
|
46
37
|
prerelease: false
|
47
38
|
version_requirements: !ruby/object:Gem::Requirement
|
48
39
|
requirements:
|
49
40
|
- - ">="
|
50
41
|
- !ruby/object:Gem::Version
|
51
|
-
version: 2.0
|
52
|
-
- - "<"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.1'
|
42
|
+
version: 2.1.0
|
55
43
|
description: Slim is a template language whose goal is reduce the syntax to the essential
|
56
44
|
parts without becoming cryptic.
|
57
45
|
email:
|
@@ -63,8 +51,8 @@ executables:
|
|
63
51
|
extensions: []
|
64
52
|
extra_rdoc_files: []
|
65
53
|
files:
|
54
|
+
- ".github/workflows/test.yml"
|
66
55
|
- ".gitignore"
|
67
|
-
- ".travis.yml"
|
68
56
|
- ".yardopts"
|
69
57
|
- CHANGES
|
70
58
|
- Gemfile
|
@@ -72,14 +60,6 @@ files:
|
|
72
60
|
- README.jp.md
|
73
61
|
- README.md
|
74
62
|
- Rakefile
|
75
|
-
- benchmarks/context.rb
|
76
|
-
- benchmarks/profile-parser.rb
|
77
|
-
- benchmarks/profile-render.rb
|
78
|
-
- benchmarks/run-benchmarks.rb
|
79
|
-
- benchmarks/run-diffbench.rb
|
80
|
-
- benchmarks/view.erb
|
81
|
-
- benchmarks/view.haml
|
82
|
-
- benchmarks/view.slim
|
83
63
|
- bin/slimrb
|
84
64
|
- doc/include.md
|
85
65
|
- doc/jp/include.md
|
@@ -106,6 +86,7 @@ files:
|
|
106
86
|
- lib/slim/logic_less/context.rb
|
107
87
|
- lib/slim/logic_less/filter.rb
|
108
88
|
- lib/slim/parser.rb
|
89
|
+
- lib/slim/railtie.rb
|
109
90
|
- lib/slim/smart.rb
|
110
91
|
- lib/slim/smart/escaper.rb
|
111
92
|
- lib/slim/smart/filter.rb
|
@@ -155,8 +136,10 @@ files:
|
|
155
136
|
- test/rails/app/helpers/application_helper.rb
|
156
137
|
- test/rails/app/models/entry.rb
|
157
138
|
- test/rails/app/views/entries/edit.html.slim
|
139
|
+
- test/rails/app/views/layouts/application.html+testvariant.slim
|
158
140
|
- test/rails/app/views/layouts/application.html.slim
|
159
141
|
- test/rails/app/views/slim/_partial.html.slim
|
142
|
+
- test/rails/app/views/slim/attributes.html.slim
|
160
143
|
- test/rails/app/views/slim/content_for.html.slim
|
161
144
|
- test/rails/app/views/slim/erb.html.erb
|
162
145
|
- test/rails/app/views/slim/form_for.html.slim
|
@@ -166,6 +149,7 @@ files:
|
|
166
149
|
- test/rails/app/views/slim/normal.html.slim
|
167
150
|
- test/rails/app/views/slim/partial.html.slim
|
168
151
|
- test/rails/app/views/slim/splat.html.slim
|
152
|
+
- test/rails/app/views/slim/splat_with_delimiter.slim
|
169
153
|
- test/rails/app/views/slim/thread_options.html.slim
|
170
154
|
- test/rails/app/views/slim/variables.html.slim
|
171
155
|
- test/rails/app/views/slim/xml.slim
|
@@ -177,7 +161,6 @@ files:
|
|
177
161
|
- test/rails/config/initializers/backtrace_silencers.rb
|
178
162
|
- test/rails/config/initializers/inflections.rb
|
179
163
|
- test/rails/config/initializers/mime_types.rb
|
180
|
-
- test/rails/config/initializers/secret_token.rb
|
181
164
|
- test/rails/config/initializers/session_store.rb
|
182
165
|
- test/rails/config/locales/en.yml
|
183
166
|
- test/rails/config/routes.rb
|
@@ -195,11 +178,18 @@ files:
|
|
195
178
|
- test/sinatra/views/layout2.slim
|
196
179
|
- test/smart/test_smart_text.rb
|
197
180
|
- test/translator/test_translator.rb
|
198
|
-
homepage:
|
181
|
+
homepage: https://slim-template.github.io/
|
199
182
|
licenses:
|
200
183
|
- MIT
|
201
|
-
metadata:
|
202
|
-
|
184
|
+
metadata:
|
185
|
+
bug_tracker_uri: https://github.com/slim-template/slim/issues
|
186
|
+
changelog_uri: https://github.com/slim-template/slim/blob/main/CHANGES
|
187
|
+
documentation_uri: https://rubydoc.info/gems/slim/frames
|
188
|
+
homepage_uri: https://slim-template.github.io/
|
189
|
+
source_code_uri: https://github.com/slim-template/slim
|
190
|
+
wiki_uri: https://github.com/slim-template/slim/wiki
|
191
|
+
funding_uri: https://github.com/sponsors/slim-template
|
192
|
+
post_install_message:
|
203
193
|
rdoc_options: []
|
204
194
|
require_paths:
|
205
195
|
- lib
|
@@ -207,15 +197,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
197
|
requirements:
|
208
198
|
- - ">="
|
209
199
|
- !ruby/object:Gem::Version
|
210
|
-
version: 2.
|
200
|
+
version: 2.5.0
|
211
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
202
|
requirements:
|
213
203
|
- - ">="
|
214
204
|
- !ruby/object:Gem::Version
|
215
205
|
version: '0'
|
216
206
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
218
|
-
signing_key:
|
207
|
+
rubygems_version: 3.4.20
|
208
|
+
signing_key:
|
219
209
|
specification_version: 4
|
220
210
|
summary: Slim is a template language.
|
221
211
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# https://www.ruby-lang.org/en/downloads/releases/
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.6.1
|
5
|
-
- 2.5.3
|
6
|
-
- 2.4.5
|
7
|
-
- jruby-9.2.6.0
|
8
|
-
- jruby-9.1.17.0
|
9
|
-
|
10
|
-
# Recommend sudo required when using trusty dist
|
11
|
-
# https://docs.travis-ci.com/user/reference/trusty/
|
12
|
-
sudo: required
|
13
|
-
dist: trusty
|
14
|
-
|
15
|
-
script: "bundle exec rake $TASK"
|
16
|
-
|
17
|
-
after_success:
|
18
|
-
- bundle exec codeclimate-test-reporter
|
19
|
-
|
20
|
-
env:
|
21
|
-
global:
|
22
|
-
- secure: "a7sD9iwPJJn3Fj+mn62GAmy/PEguh3elrilsp1KS+WfDiCiIKD8Q5KG2Jv67DGcQAGI3dPWeh7+ZhZ/W7nEipwWUBmSvGYVeoF63y8j6mNRLeekqspj94l47hXyFePj9bCadY1b1/xY4lE1pMEU8eA8AOUHUqCSuH+Kk/MuvyLM="
|
23
|
-
matrix:
|
24
|
-
- "TASK=test:core_and_plugins"
|
25
|
-
- "TASK=test:rails RAILS=6.0.0.beta2"
|
26
|
-
- "TASK=test:rails RAILS=5.2.2"
|
27
|
-
- "TASK=test:rails RAILS=5.2.1.1"
|
28
|
-
- "TASK=test:rails RAILS=5.2.1"
|
29
|
-
- "TASK=test:sinatra SINATRA=2.0.5"
|
30
|
-
- "TASK=test:sinatra SINATRA=2.0.4"
|
31
|
-
- "TASK=test:sinatra SINATRA=2.0.3"
|
32
|
-
|
33
|
-
matrix:
|
34
|
-
exclude:
|
35
|
-
- rvm: 2.4.5
|
36
|
-
env: "TASK=test:rails RAILS=6.0.0.beta2"
|
37
|
-
- rvm: jruby-9.1.17.0
|
38
|
-
env: "TASK=test:rails RAILS=6.0.0.beta2"
|
data/benchmarks/context.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'slim'
|
6
|
-
require 'context'
|
7
|
-
|
8
|
-
content = File.read(File.dirname(__FILE__) + '/view.slim')
|
9
|
-
slim = Slim::Template.new { content }
|
10
|
-
context = Context.new
|
11
|
-
|
12
|
-
10000.times { slim.render(context) }
|
@@ -1,120 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'slim'
|
6
|
-
require 'context'
|
7
|
-
|
8
|
-
require 'benchmark/ips'
|
9
|
-
require 'tilt'
|
10
|
-
require 'erubis'
|
11
|
-
require 'erb'
|
12
|
-
require 'haml'
|
13
|
-
|
14
|
-
class SlimBenchmarks
|
15
|
-
def initialize(slow)
|
16
|
-
@benches = Hash.new { |h, k| h[k] = [] }
|
17
|
-
|
18
|
-
@erb_code = File.read(File.dirname(__FILE__) + '/view.erb')
|
19
|
-
@haml_code = File.read(File.dirname(__FILE__) + '/view.haml')
|
20
|
-
@slim_code = File.read(File.dirname(__FILE__) + '/view.slim')
|
21
|
-
|
22
|
-
init_compiled_benches
|
23
|
-
init_tilt_benches
|
24
|
-
init_parsing_benches if slow
|
25
|
-
end
|
26
|
-
|
27
|
-
def init_compiled_benches
|
28
|
-
haml = Haml::Engine.new(@haml_code, format: :html5, escape_attrs: false)
|
29
|
-
|
30
|
-
context = Context.new
|
31
|
-
|
32
|
-
haml.def_method(context, :run_haml)
|
33
|
-
context.instance_eval %{
|
34
|
-
def run_erb; #{ERB.new(@erb_code).src}; end
|
35
|
-
def run_erubis; #{Erubis::Eruby.new(@erb_code).src}; end
|
36
|
-
def run_temple_erb; #{Temple::ERB::Engine.new.call @erb_code}; end
|
37
|
-
def run_fast_erubis; #{Erubis::FastEruby.new(@erb_code).src}; end
|
38
|
-
def run_slim_pretty; #{Slim::Engine.new(pretty: true).call @slim_code}; end
|
39
|
-
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
40
|
-
}
|
41
|
-
|
42
|
-
bench(:compiled, 'erb') { context.run_erb }
|
43
|
-
bench(:compiled, 'erubis') { context.run_erubis }
|
44
|
-
bench(:compiled, 'fast erubis') { context.run_fast_erubis }
|
45
|
-
bench(:compiled, 'temple erb') { context.run_temple_erb }
|
46
|
-
bench(:compiled, 'slim pretty') { context.run_slim_pretty }
|
47
|
-
bench(:compiled, 'slim ugly') { context.run_slim_ugly }
|
48
|
-
bench(:compiled, 'haml') { context.run_haml }
|
49
|
-
end
|
50
|
-
|
51
|
-
def init_tilt_benches
|
52
|
-
tilt_erb = Tilt::ERBTemplate.new { @erb_code }
|
53
|
-
tilt_erubis = Tilt::ErubisTemplate.new { @erb_code }
|
54
|
-
tilt_temple_erb = Temple::ERB::Template.new { @erb_code }
|
55
|
-
tilt_haml = Tilt::HamlTemplate.new(format: :html5) { @haml_code }
|
56
|
-
tilt_slim_pretty = Slim::Template.new(pretty: true) { @slim_code }
|
57
|
-
tilt_slim_ugly = Slim::Template.new { @slim_code }
|
58
|
-
|
59
|
-
context = Context.new
|
60
|
-
|
61
|
-
bench(:tilt, 'erb') { tilt_erb.render(context) }
|
62
|
-
bench(:tilt, 'erubis') { tilt_erubis.render(context) }
|
63
|
-
bench(:tilt, 'temple erb') { tilt_temple_erb.render(context) }
|
64
|
-
bench(:tilt, 'slim pretty') { tilt_slim_pretty.render(context) }
|
65
|
-
bench(:tilt, 'slim ugly') { tilt_slim_ugly.render(context) }
|
66
|
-
bench(:tilt, 'haml') { tilt_haml.render(context) }
|
67
|
-
end
|
68
|
-
|
69
|
-
def init_parsing_benches
|
70
|
-
context = Context.new
|
71
|
-
context_binding = context.instance_eval { binding }
|
72
|
-
|
73
|
-
bench(:parsing, 'erb') { ERB.new(@erb_code).result(context_binding) }
|
74
|
-
bench(:parsing, 'erubis') { Erubis::Eruby.new(@erb_code).result(context_binding) }
|
75
|
-
bench(:parsing, 'fast erubis') { Erubis::FastEruby.new(@erb_code).result(context_binding) }
|
76
|
-
bench(:parsing, 'temple erb') { Temple::ERB::Template.new { @erb_code }.render(context) }
|
77
|
-
bench(:parsing, 'slim pretty') { Slim::Template.new(pretty: true) { @slim_code }.render(context) }
|
78
|
-
bench(:parsing, 'slim ugly') { Slim::Template.new { @slim_code }.render(context) }
|
79
|
-
bench(:parsing, 'haml') { Haml::Engine.new(@haml_code, format: :html5).render(context) }
|
80
|
-
end
|
81
|
-
|
82
|
-
def run
|
83
|
-
@benches.each do |group_name, group_benches|
|
84
|
-
puts "Running #{group_name} benchmarks:"
|
85
|
-
|
86
|
-
Benchmark.ips do |x|
|
87
|
-
group_benches.each do |name, block|
|
88
|
-
x.report("#{group_name} #{name}", &block)
|
89
|
-
end
|
90
|
-
|
91
|
-
x.compare!
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
puts "
|
96
|
-
Compiled benchmark: Template is parsed before the benchmark and
|
97
|
-
generated ruby code is compiled into a method.
|
98
|
-
This is the fastest evaluation strategy because it benchmarks
|
99
|
-
pure execution speed of the generated ruby code.
|
100
|
-
|
101
|
-
Compiled Tilt benchmark: Template is compiled with Tilt, which gives a more
|
102
|
-
accurate result of the performance in production mode in frameworks like
|
103
|
-
Sinatra, Ramaze and Camping. (Rails still uses its own template
|
104
|
-
compilation.)
|
105
|
-
|
106
|
-
Parsing benchmark: Template is parsed every time.
|
107
|
-
This is not the recommended way to use the template engine
|
108
|
-
and Slim is not optimized for it. Activate this benchmark with 'rake bench slow=1'.
|
109
|
-
|
110
|
-
Temple ERB is the ERB implementation using the Temple framework. It shows the
|
111
|
-
overhead added by the Temple framework compared to ERB.
|
112
|
-
"
|
113
|
-
end
|
114
|
-
|
115
|
-
def bench(group, name, &block)
|
116
|
-
@benches[group].push([name, block])
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
SlimBenchmarks.new(ENV['slow']).run
|
data/benchmarks/run-diffbench.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
4
|
-
|
5
|
-
require 'slim'
|
6
|
-
require 'context'
|
7
|
-
require 'diffbench'
|
8
|
-
|
9
|
-
content = File.read(File.dirname(__FILE__) + '/view.slim')
|
10
|
-
engine = Slim::Engine.new
|
11
|
-
template = Slim::Template.new { content }
|
12
|
-
context = Context.new
|
13
|
-
|
14
|
-
DiffBench.bm do
|
15
|
-
report("Parse") do
|
16
|
-
2000.times { engine.call(content) }
|
17
|
-
end
|
18
|
-
report("Render") do
|
19
|
-
100000.times { template.render(context) }
|
20
|
-
end
|
21
|
-
end
|
data/benchmarks/view.erb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML>
|
2
|
-
|
3
|
-
<html lang="en">
|
4
|
-
<head>
|
5
|
-
<title>Simple Benchmark</title>
|
6
|
-
<meta charset="utf-8">
|
7
|
-
<meta name="description" content="This is an example of a meta description.">
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
<h1><%= header %></h1>
|
11
|
-
<% unless item.empty? %>
|
12
|
-
<ul>
|
13
|
-
<% for i in item %>
|
14
|
-
<% if i[:current] %>
|
15
|
-
<li><strong><%= i[:name] %></strong></li>
|
16
|
-
<% else %>
|
17
|
-
<li><a href="<%= i[:url] %>"><%= i[:name] %></a></li>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
20
|
-
</ul>
|
21
|
-
<% else %>
|
22
|
-
<p>The list is empty.</p>
|
23
|
-
<% end %>
|
24
|
-
</body>
|
25
|
-
</html>
|
data/benchmarks/view.haml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
!!! html
|
2
|
-
|
3
|
-
%html{ lang: "en" }
|
4
|
-
%head
|
5
|
-
%title Simple Benchmark
|
6
|
-
%meta{ charset: "utf-8" }
|
7
|
-
%meta{ name: "description", content: "This is an example of a meta description." }
|
8
|
-
%body
|
9
|
-
%h1= header
|
10
|
-
- unless item.empty?
|
11
|
-
%ul
|
12
|
-
- for i in item
|
13
|
-
- if i[:current]
|
14
|
-
%li
|
15
|
-
%strong= i[:name]
|
16
|
-
- else
|
17
|
-
%li
|
18
|
-
%a{:href => i[:url]}= i[:name]
|
19
|
-
- else
|
20
|
-
%p The list is empty.
|
data/benchmarks/view.slim
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
doctype html
|
2
|
-
html lang="en"
|
3
|
-
head
|
4
|
-
title Simple Benchmark
|
5
|
-
meta charset="utf-8"
|
6
|
-
meta name="description" content="This is an example of a meta description."
|
7
|
-
body
|
8
|
-
h1 == header
|
9
|
-
- unless item.empty?
|
10
|
-
ul
|
11
|
-
- for i in item
|
12
|
-
- if i[:current]
|
13
|
-
li
|
14
|
-
strong == i[:name]
|
15
|
-
- else
|
16
|
-
li
|
17
|
-
a href==i[:url] == i[:name]
|
18
|
-
- else
|
19
|
-
p The list is empty.
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Your secret key for verifying the integrity of signed cookies.
|
4
|
-
# If you change this key, all old signed cookies will become invalid!
|
5
|
-
# Make sure the secret is at least 30 characters and all random,
|
6
|
-
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
Dummy::Application.config.secret_token = Dummy::Application.config.secret_key_base = '123a9119fb14a410f485f9390286b33f2743b9d348246cf3e4434522078f77c202d7a1fb7e42666dd0844bcb10d0ff3d8b4ee087796269d4c574837948512dbf'
|