haml 5.0.4 → 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/.gitignore +1 -0
- data/.travis.yml +78 -21
- data/.yardopts +1 -2
- data/CHANGELOG.md +43 -1
- data/Gemfile +2 -5
- data/MIT-LICENSE +2 -2
- data/README.md +4 -5
- data/REFERENCE.md +36 -9
- data/Rakefile +2 -13
- data/benchmark.rb +13 -9
- data/haml.gemspec +10 -3
- data/lib/haml.rb +1 -0
- data/lib/haml/attribute_builder.rb +4 -3
- data/lib/haml/attribute_compiler.rb +43 -31
- data/lib/haml/attribute_parser.rb +3 -1
- data/lib/haml/buffer.rb +4 -1
- data/lib/haml/compiler.rb +23 -24
- data/lib/haml/engine.rb +12 -3
- data/lib/haml/error.rb +25 -24
- data/lib/haml/escapable.rb +39 -11
- data/lib/haml/exec.rb +5 -6
- data/lib/haml/filters.rb +12 -11
- data/lib/haml/generator.rb +2 -1
- data/lib/haml/helpers.rb +15 -13
- data/lib/haml/helpers/action_view_extensions.rb +1 -0
- data/lib/haml/helpers/action_view_mods.rb +4 -1
- data/lib/haml/helpers/action_view_xss_mods.rb +1 -0
- data/lib/haml/helpers/safe_erubi_template.rb +1 -0
- data/lib/haml/helpers/safe_erubis_template.rb +1 -0
- data/lib/haml/helpers/xss_mods.rb +7 -3
- data/lib/haml/options.rb +36 -36
- data/lib/haml/parser.rb +52 -22
- data/lib/haml/plugin.rb +7 -4
- data/lib/haml/railtie.rb +4 -4
- data/lib/haml/sass_rails_filter.rb +1 -0
- data/lib/haml/template.rb +1 -0
- data/lib/haml/template/options.rb +1 -0
- data/lib/haml/temple_engine.rb +11 -9
- data/lib/haml/temple_line_counter.rb +1 -0
- data/lib/haml/util.rb +6 -6
- data/lib/haml/version.rb +2 -1
- metadata +28 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3182fca5b2f85849a1abd849d3352858834737b83b7d57d4d29c19e84518f1c
|
4
|
+
data.tar.gz: ea005149aeccb8247ff121a4a33b3118d289f18ed5f12b101fd739892fb4edae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8fcd8c9cb45217a405820c13d69330ef53c82aa22b25026d0886937505a5dc101803c55087f74cc5467a1930f43bd5ab6fd7d44d69e1234aeab06db634b8fdd
|
7
|
+
data.tar.gz: b8c0f35f75c6beac4e27c7066eefbf8385346abecbdab2cb3303b2ea2a3f19dfc2d209f171c0801d383d9bc3bd526721e674939e808ec2763712bbd94c7110d8
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
sudo: false
|
2
2
|
dist: trusty
|
3
3
|
language: ruby
|
4
|
-
cache:
|
4
|
+
cache:
|
5
|
+
bundler: true
|
5
6
|
rvm:
|
6
7
|
- ruby-head
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2
|
11
|
-
|
12
|
-
-
|
13
|
-
-
|
8
|
+
- 2.7
|
9
|
+
- 2.6
|
10
|
+
- 2.5
|
11
|
+
- jruby-9.2
|
12
|
+
env:
|
13
|
+
- RUBYOPT="--enable-frozen-string-literal"
|
14
|
+
- RUBYOPT=""
|
14
15
|
gemfile:
|
16
|
+
- test/gemfiles/Gemfile.rails-6.0.x
|
17
|
+
- test/gemfiles/Gemfile.rails-5.2.x
|
15
18
|
- test/gemfiles/Gemfile.rails-5.1.x
|
16
19
|
- test/gemfiles/Gemfile.rails-5.0.x
|
17
20
|
- test/gemfiles/Gemfile.rails-5.0.x.erubi
|
@@ -20,35 +23,89 @@ gemfile:
|
|
20
23
|
- test/gemfiles/Gemfile.rails-4.0.x
|
21
24
|
matrix:
|
22
25
|
exclude:
|
23
|
-
- rvm: 2.
|
24
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
25
|
-
- rvm: 2.
|
26
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
27
|
-
- rvm: 2.
|
26
|
+
- rvm: 2.5
|
27
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
28
|
+
- rvm: 2.5
|
29
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
30
|
+
- rvm: 2.5
|
31
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
32
|
+
- rvm: 2.5
|
28
33
|
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
29
|
-
|
34
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
35
|
+
- rvm: 2.5
|
30
36
|
gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
|
31
|
-
|
37
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
38
|
+
- rvm: 2.5
|
39
|
+
gemfile: test/gemfiles/Gemfile.rails-5.1.x
|
40
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
41
|
+
- rvm: 2.6
|
42
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
43
|
+
- rvm: 2.6
|
44
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
45
|
+
- rvm: 2.6
|
46
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
47
|
+
- rvm: 2.6
|
32
48
|
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
33
|
-
|
49
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
50
|
+
- rvm: 2.6
|
34
51
|
gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
|
35
|
-
|
52
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
53
|
+
- rvm: 2.6
|
54
|
+
gemfile: test/gemfiles/Gemfile.rails-5.1.x
|
55
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
56
|
+
- rvm: 2.7
|
36
57
|
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
37
|
-
- rvm: 2.
|
58
|
+
- rvm: 2.7
|
38
59
|
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
39
|
-
- rvm: 2.
|
60
|
+
- rvm: 2.7
|
40
61
|
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
62
|
+
- rvm: 2.7
|
63
|
+
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
64
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
65
|
+
- rvm: 2.7
|
66
|
+
gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
|
67
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
68
|
+
- rvm: 2.7
|
69
|
+
gemfile: test/gemfiles/Gemfile.rails-5.1.x
|
70
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
41
71
|
- rvm: ruby-head
|
42
72
|
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
43
73
|
- rvm: ruby-head
|
44
74
|
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
45
75
|
- rvm: ruby-head
|
46
76
|
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
77
|
+
- rvm: jruby-9.2
|
78
|
+
gemfile: test/gemfiles/Gemfile.rails-5.0.x
|
79
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
80
|
+
- rvm: jruby-9.2
|
81
|
+
gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
|
82
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
83
|
+
- rvm: jruby-9.2
|
84
|
+
gemfile: test/gemfiles/Gemfile.rails-5.1.x
|
85
|
+
env: RUBYOPT="--enable-frozen-string-literal"
|
47
86
|
include:
|
48
|
-
- rvm: 2.
|
87
|
+
- rvm: 2.7
|
49
88
|
gemfile: test/gemfiles/Gemfile.rails-edge
|
50
89
|
allow_failures:
|
51
|
-
- rvm:
|
90
|
+
- rvm: ruby-head
|
52
91
|
- gemfile: test/gemfiles/Gemfile.rails-edge
|
92
|
+
- rvm: jruby-9.2
|
93
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
94
|
+
- rvm: jruby-9.2
|
95
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
96
|
+
- rvm: jruby-9.2
|
97
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
98
|
+
- rvm: jruby-9.2
|
99
|
+
gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
|
53
100
|
fast_finish: true
|
101
|
+
before_install:
|
102
|
+
# install older versions of rubygems and bundler only on Ruby < 2.7
|
103
|
+
- if [ `echo "${TRAVIS_RUBY_VERSION:0:3} < 2.7" | bc` == 1 ]; then gem i rubygems-update -v '<3' && update_rubygems; fi; # https://github.com/travis-ci/travis-ci/issues/8974
|
104
|
+
- if [ `echo "${TRAVIS_RUBY_VERSION:0:3} < 2.7" | bc` == 1 ]; then gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true; fi;
|
105
|
+
- if [ `echo "${TRAVIS_RUBY_VERSION:0:3} < 2.7" | bc` == 1 ]; then gem i bundler -v '<2'; fi;
|
106
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
107
|
+
- chmod +x ./cc-test-reporter
|
108
|
+
- ./cc-test-reporter before-build
|
54
109
|
script: "bundle exec rake submodules test"
|
110
|
+
after_script:
|
111
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/.yardopts
CHANGED
@@ -7,8 +7,7 @@
|
|
7
7
|
--title "Haml Documentation"
|
8
8
|
--query 'object.type != :classvariable'
|
9
9
|
--query 'object.type != :constant || @api && @api.text == "public"'
|
10
|
-
--exclude lib/haml/
|
11
|
-
--exclude lib/haml/template/plugin.rb
|
10
|
+
--exclude lib/haml/plugin.rb
|
12
11
|
--exclude lib/haml/railtie.rb
|
13
12
|
--exclude lib/haml/helpers/action_view_mods.rb
|
14
13
|
--exclude lib/haml/helpers/xss_mods.rb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,48 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
|
+
## 5.2.1
|
4
|
+
|
5
|
+
Released on November 30, 2020
|
6
|
+
([diff](https://github.com/haml/haml/compare/v5.2.0...v5.2.1)).
|
7
|
+
|
8
|
+
* Add in improved "multiline" support for attributes [#1043](https://github.com/haml/haml/issues/1043)
|
9
|
+
|
10
|
+
## 5.2
|
11
|
+
|
12
|
+
Released on September 28, 2020
|
13
|
+
([diff](https://github.com/haml/haml/compare/v5.1.2...v5.2.0)).
|
14
|
+
|
15
|
+
* Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](https://github.com/haml/haml/issues/972)
|
16
|
+
* Do not HTML-escape templates that are declared to be plaintext [#1014](https://github.com/haml/haml/issues/1014) (Thanks [@cesarizu](https://github.com/cesarizu))
|
17
|
+
* Class names are no longer ordered alphabetically, and now follow a new specification as laid out in REFERENCE [#306](https://github.com/haml/haml/issues/306)
|
18
|
+
|
19
|
+
## 5.1.2
|
20
|
+
|
21
|
+
Released on August 6, 2019
|
22
|
+
([diff](https://github.com/haml/haml/compare/v5.1.1...v5.1.2)).
|
23
|
+
|
24
|
+
* Fix crash in some environments such as New Relic by unfreezing string literals for ParseNode#inspect. [#1016](https://github.com/haml/haml/pull/1016) (thanks [Jalyna](https://github.com/jalyna))
|
25
|
+
|
26
|
+
## 5.1.1
|
27
|
+
|
28
|
+
Released on May 25, 2019
|
29
|
+
([diff](https://github.com/haml/haml/compare/v5.1.0...v5.1.1)).
|
30
|
+
|
31
|
+
* Fix NameError bug that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails < 5.1 + erubi. (Akira Matsuda)
|
32
|
+
|
33
|
+
## 5.1.0
|
34
|
+
|
35
|
+
Released on May 16, 2019
|
36
|
+
([diff](https://github.com/haml/haml/compare/v5.0.4...v5.1.0)).
|
37
|
+
|
38
|
+
* Rails 6 support [#1008](https://github.com/haml/haml/pull/1008) (thanks [Seb Jacobs](https://github.com/sebjacobs))
|
39
|
+
* Add `escape_filter_interpolations` option for backwards compatibility with haml 4 defaults [#984](https://github.com/haml/haml/pull/984) (thanks [Will Jordan](https://github.com/wjordan))
|
40
|
+
* Fix error on empty :javascript and :css filter blocks [#986](https://github.com/haml/haml/pull/986) (thanks [Will Jordan](https://github.com/wjordan))
|
41
|
+
* Respect changes in Haml::Options.defaults in `Haml::TempleEngine` options (Takashi Kokubun)
|
42
|
+
* Un-freeze TempleEngine precompiled string literals [#983](https://github.com/haml/haml/pull/983) (thanks [Will Jordan](https://github.com/wjordan))
|
43
|
+
* Various performance/memory improvements [#965](https://github.com/haml/haml/pull/965), [#966](https://github.com/haml/haml/pull/966), [#963](https://github.com/haml/haml/pull/963) (thanks [Dillon Welch](https://github.com/oniofchaos))
|
44
|
+
* Enable `frozen_string_literal` magic comment for all .rb files [#967](https://github.com/haml/haml/pull/967) (thanks [Dillon Welch](https://github.com/oniofchaos))
|
45
|
+
|
3
46
|
## 5.0.4
|
4
47
|
|
5
48
|
Released on October 13, 2017
|
@@ -1452,4 +1495,3 @@ has been moved to [YARD](http://yard.soen.ca).
|
|
1452
1495
|
YARD is an excellent documentation system,
|
1453
1496
|
and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
|
1454
1497
|
which is also excellent.
|
1455
|
-
>>>>>>> External Changes
|
data/Gemfile
CHANGED
@@ -3,9 +3,10 @@ gemspec
|
|
3
3
|
|
4
4
|
gem "m"
|
5
5
|
gem "pry"
|
6
|
+
gem "simplecov"
|
6
7
|
|
7
8
|
group :docs do
|
8
|
-
gem "yard"
|
9
|
+
gem "yard"
|
9
10
|
gem "kramdown"
|
10
11
|
gem "sass"
|
11
12
|
end
|
@@ -13,7 +14,3 @@ end
|
|
13
14
|
platform :mri do
|
14
15
|
gem "ruby-prof"
|
15
16
|
end
|
16
|
-
|
17
|
-
platform :mri_21 do
|
18
|
-
gem "simplecov"
|
19
|
-
end
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006-
|
1
|
+
Copyright (c) 2006-2019 Hampton Catlin and Natalie Weizenbaum
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# Haml
|
2
2
|
|
3
3
|
[](http://rubygems.org/gems/haml)
|
4
|
-
[](https://coveralls.io/r/haml/haml)
|
4
|
+
[](http://travis-ci.org/haml/haml)
|
5
|
+
[](https://codeclimate.com/github/haml/haml)
|
7
6
|
[](http://inch-ci.org/github/haml/haml)
|
8
7
|
|
9
8
|
Haml is a templating engine for HTML. It's designed to make it both easier and
|
@@ -32,7 +31,7 @@ to compile it to HTML. For more information on these commands, check out
|
|
32
31
|
haml --help
|
33
32
|
~~~
|
34
33
|
|
35
|
-
To use Haml
|
34
|
+
To use Haml programmatically, check out the [YARD documentation](http://haml.info/docs/yardoc/).
|
36
35
|
|
37
36
|
## Using Haml with Rails
|
38
37
|
|
@@ -191,7 +190,7 @@ Some of Natalie's work on Haml was supported by Unspace Interactive.
|
|
191
190
|
|
192
191
|
Beyond that, the implementation is licensed under the MIT License.
|
193
192
|
|
194
|
-
Copyright (c) 2006-
|
193
|
+
Copyright (c) 2006-2019 Hampton Catlin, Natalie Weizenbaum and the Haml team
|
195
194
|
|
196
195
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
197
196
|
this software and associated documentation files (the "Software"), to deal in
|
data/REFERENCE.md
CHANGED
@@ -115,6 +115,11 @@ Haml::Options.defaults:
|
|
115
115
|
|
116
116
|
Haml::Options.defaults[:format] = :html5
|
117
117
|
|
118
|
+
In sinatra specifically, you can set them in global config with:
|
119
|
+
```ruby
|
120
|
+
set :haml, { escape_html: true }
|
121
|
+
```
|
122
|
+
|
118
123
|
Finally, you can also set them by passing an options hash to
|
119
124
|
{Haml::Engine#initialize}. For the complete list of available options, please
|
120
125
|
see {Haml::Options}.
|
@@ -223,15 +228,19 @@ is compiled to:
|
|
223
228
|
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'></html>
|
224
229
|
|
225
230
|
Attribute hashes can also be stretched out over multiple lines to accommodate
|
226
|
-
many attributes.
|
227
|
-
For example:
|
231
|
+
many attributes.
|
228
232
|
|
229
|
-
%script{
|
230
|
-
|
233
|
+
%script{
|
234
|
+
"type": text/javascript",
|
235
|
+
"src": javascripts/script_#{2 + 7}",
|
236
|
+
"data": {
|
237
|
+
"controller": "reporter",
|
238
|
+
},
|
239
|
+
}
|
231
240
|
|
232
241
|
is compiled to:
|
233
242
|
|
234
|
-
<script src='javascripts/script_9' type='text/javascript'></script>
|
243
|
+
<script src='javascripts/script_9' type='text/javascript' data-controller='reporter'></script>
|
235
244
|
|
236
245
|
#### `:class` and `:id` Attributes {#class-and-id-attributes}
|
237
246
|
|
@@ -512,6 +521,24 @@ and is compiled to:
|
|
512
521
|
</div>
|
513
522
|
</div>
|
514
523
|
|
524
|
+
#### Class Name Merging and Ordering
|
525
|
+
|
526
|
+
Class names are ordered in the following way:
|
527
|
+
|
528
|
+
1) Tag identifiers in order (aka, ".alert.me" => "alert me")
|
529
|
+
2) Classes appearing in HTML-style attributes
|
530
|
+
3) Classes appearing in Hash-style attributes
|
531
|
+
|
532
|
+
For instance, this is a complicated and unintuitive test case illustrating the ordering
|
533
|
+
|
534
|
+
.foo.moo{:class => ['bar', 'alpha']}(class='baz')
|
535
|
+
|
536
|
+
The resulting HTML would be as follows:
|
537
|
+
|
538
|
+
<div class='foo moo baz bar alpha'></div>
|
539
|
+
|
540
|
+
*Versions of Haml prior to 5.0 would alphabetically sort class names.*
|
541
|
+
|
515
542
|
### Empty (void) Tags: `/`
|
516
543
|
|
517
544
|
The forward slash character, when placed at the end of a tag definition, causes
|
@@ -848,7 +875,7 @@ is compiled to:
|
|
848
875
|
|
849
876
|
## Ruby Evaluation
|
850
877
|
|
851
|
-
### Inserting Ruby: `=`
|
878
|
+
### Inserting Ruby: `=` {#inserting_ruby}
|
852
879
|
|
853
880
|
The equals character is followed by Ruby code. This code is evaluated and the
|
854
881
|
output is inserted into the document. For example:
|
@@ -1120,8 +1147,8 @@ is compiled to
|
|
1120
1147
|
<p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
|
1121
1148
|
</div>
|
1122
1149
|
|
1123
|
-
Note that `#{}` interpolation within filters is HTML-escaped if you specify
|
1124
|
-
{Haml::Options#
|
1150
|
+
Note that `#{}` interpolation within filters is HTML-escaped if you specify true to
|
1151
|
+
{Haml::Options#escape_filter_interpolations `:escape_filter_interpolations`} option.
|
1125
1152
|
|
1126
1153
|
The functionality of some filters such as Markdown can be provided by many
|
1127
1154
|
different libraries. Usually you don't have to worry about this - you can just
|
@@ -1318,7 +1345,7 @@ that just need a lot of template information.
|
|
1318
1345
|
So data structures and functions that require lots of arguments
|
1319
1346
|
can be wrapped over multiple lines,
|
1320
1347
|
as long as each line but the last ends in a comma
|
1321
|
-
(see [Inserting Ruby](#
|
1348
|
+
(see [Inserting Ruby](#inserting_ruby)).
|
1322
1349
|
|
1323
1350
|
## Whitespace Preservation
|
1324
1351
|
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ isolated_test = Rake::TestTask.new do |t|
|
|
14
14
|
end
|
15
15
|
Rake::TestTask.new do |t|
|
16
16
|
t.libs << 'test'
|
17
|
-
t.test_files = Dir['test/*_test.rb'] + Dir['test/haml-spec/*_test.rb'] - isolated_test.file_list
|
17
|
+
t.test_files = Dir['test/*_test.rb'] + Dir['test/haml-spec/*_test.rb'] + Dir['test/cases/*_test.rb'] - isolated_test.file_list
|
18
18
|
t.warning = true
|
19
19
|
t.verbose = true
|
20
20
|
end
|
@@ -26,13 +26,6 @@ task :benchmark do
|
|
26
26
|
sh "ruby benchmark.rb #{ENV['TIMES']}"
|
27
27
|
end
|
28
28
|
|
29
|
-
task :set_coverage_env do
|
30
|
-
ENV["COVERAGE"] = "true"
|
31
|
-
end
|
32
|
-
|
33
|
-
desc "Run Simplecov"
|
34
|
-
task :coverage => [:set_coverage_env, :test]
|
35
|
-
|
36
29
|
task :submodules do
|
37
30
|
if File.exist?(File.dirname(__FILE__) + "/.git")
|
38
31
|
sh %{git submodule sync}
|
@@ -88,11 +81,7 @@ task :profile do
|
|
88
81
|
end
|
89
82
|
|
90
83
|
def gemfiles
|
91
|
-
@gemfiles ||=
|
92
|
-
Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].
|
93
|
-
reject {|f| f =~ /\.lock$/}.
|
94
|
-
reject {|f| RUBY_VERSION < '1.9.3' && f =~ /Gemfile.rails-(\d+).\d+.x/ && $1.to_i > 3}
|
95
|
-
end
|
84
|
+
@gemfiles ||= Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].reject {|f| f =~ /\.lock$/}
|
96
85
|
end
|
97
86
|
|
98
87
|
def with_each_gemfile
|
data/benchmark.rb
CHANGED
@@ -12,7 +12,7 @@ END
|
|
12
12
|
exit 1
|
13
13
|
end
|
14
14
|
|
15
|
-
%w[erb
|
15
|
+
%w[erb erubi rails active_support action_controller
|
16
16
|
action_view action_pack haml/template rbench].each {|dep| require(dep)}
|
17
17
|
|
18
18
|
def view
|
@@ -28,7 +28,7 @@ end
|
|
28
28
|
RBench.run(times) do
|
29
29
|
column :haml, :title => "Haml"
|
30
30
|
column :erb, :title => "ERB"
|
31
|
-
column :
|
31
|
+
column :erubi, :title => "Erubi"
|
32
32
|
|
33
33
|
template_name = 'standard'
|
34
34
|
haml_template = File.read("#{File.dirname(__FILE__)}/test/templates/#{template_name}.haml")
|
@@ -38,12 +38,16 @@ RBench.run(times) do
|
|
38
38
|
obj = Object.new
|
39
39
|
|
40
40
|
Haml::Engine.new(haml_template).def_method(obj, :haml)
|
41
|
-
|
42
|
-
|
41
|
+
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
42
|
+
obj.instance_eval("def erb; #{ERB.new(erb_template, trim_mode: '-').src}; end")
|
43
|
+
else
|
44
|
+
obj.instance_eval("def erb; #{ERB.new(erb_template, nil, '-').src}; end")
|
45
|
+
end
|
46
|
+
obj.instance_eval("def erubi; #{Erubi::Engine.new(erb_template).src}; end")
|
43
47
|
|
44
48
|
haml { obj.haml }
|
45
49
|
erb { obj.erb }
|
46
|
-
|
50
|
+
erubi { obj.erubi }
|
47
51
|
end
|
48
52
|
|
49
53
|
report "ActionView" do
|
@@ -51,8 +55,8 @@ RBench.run(times) do
|
|
51
55
|
render view, 'templates/standard'
|
52
56
|
render view, 'erb/standard'
|
53
57
|
|
54
|
-
haml
|
55
|
-
|
58
|
+
haml { render view, 'templates/standard' }
|
59
|
+
erubi { render view, 'erb/standard' }
|
56
60
|
end
|
57
61
|
|
58
62
|
report "ActionView with deep partials" do
|
@@ -60,7 +64,7 @@ RBench.run(times) do
|
|
60
64
|
render view, 'templates/action_view'
|
61
65
|
render view, 'erb/action_view'
|
62
66
|
|
63
|
-
haml
|
64
|
-
|
67
|
+
haml { render view, 'templates/action_view' }
|
68
|
+
erubi { render view, 'erb/action_view' }
|
65
69
|
end
|
66
70
|
end
|