haml 5.0.3 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +50 -25
- data/.yardopts +1 -2
- data/CHANGELOG.md +44 -1
- data/Gemfile +2 -5
- data/MIT-LICENSE +2 -2
- data/README.md +4 -5
- data/REFERENCE.md +27 -4
- 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 +6 -4
- 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 +21 -19
- 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 +5 -5
- data/lib/haml/version.rb +2 -1
- metadata +28 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ccbf9b5c93745c83284467b77b73dd156f049dacf55861dd486bd14404d84e84
|
4
|
+
data.tar.gz: 4e2439c5e370db4bd765ca76ab4d76c027d9a9f9f6b68e5d38761e6858f3312f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c7b716e9866070fc50281e4486eb519832c3f098cbd58bb62ca18f2659ca85bc44cd6a275121fe71f37f8d9e442ac9b75f254b28747b5fbff47a98b1e633c5
|
7
|
+
data.tar.gz: 3e870080f42d925cddc479a52318d2cb8e6a9dbfd5613e8027c0c4dfd80e4f7636fa9f50cd41d3eca6f72f12bcc1cc7e5a5b2b9120223e1e6218ad8d6dcf9ca8
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
sudo: false
|
2
2
|
dist: trusty
|
3
3
|
language: ruby
|
4
|
-
cache:
|
4
|
+
cache:
|
5
|
+
bundler: true
|
5
6
|
rvm:
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2
|
11
|
-
- jruby-9.1.12.0
|
12
|
-
- rbx-3
|
7
|
+
- ruby-head
|
8
|
+
- 2.7
|
9
|
+
- 2.6
|
10
|
+
- 2.5
|
11
|
+
- jruby-9.2
|
13
12
|
gemfile:
|
13
|
+
- test/gemfiles/Gemfile.rails-6.0.x
|
14
|
+
- test/gemfiles/Gemfile.rails-5.2.x
|
14
15
|
- test/gemfiles/Gemfile.rails-5.1.x
|
15
16
|
- test/gemfiles/Gemfile.rails-5.0.x
|
16
17
|
- test/gemfiles/Gemfile.rails-5.0.x.erubi
|
@@ -19,29 +20,53 @@ gemfile:
|
|
19
20
|
- test/gemfiles/Gemfile.rails-4.0.x
|
20
21
|
matrix:
|
21
22
|
exclude:
|
22
|
-
- rvm: 2.
|
23
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
24
|
-
- rvm: 2.
|
25
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
26
|
-
- rvm: 2.
|
27
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
28
|
-
- rvm: 2.
|
29
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
30
|
-
- rvm: 2.
|
31
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
32
|
-
- rvm: 2.
|
33
|
-
gemfile: test/gemfiles/Gemfile.rails-
|
34
|
-
- rvm: 2.
|
23
|
+
- rvm: 2.5
|
24
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
25
|
+
- rvm: 2.5
|
26
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
27
|
+
- rvm: 2.5
|
28
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
29
|
+
- rvm: 2.6
|
30
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
31
|
+
- rvm: 2.6
|
32
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
33
|
+
- rvm: 2.6
|
34
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
35
|
+
- rvm: 2.7
|
35
36
|
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
36
|
-
- rvm: 2.
|
37
|
+
- rvm: 2.7
|
37
38
|
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
38
|
-
- rvm: 2.
|
39
|
+
- rvm: 2.7
|
40
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
41
|
+
- rvm: ruby-head
|
42
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
43
|
+
- rvm: ruby-head
|
44
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
45
|
+
- rvm: ruby-head
|
39
46
|
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
40
47
|
include:
|
41
|
-
- rvm: 2.
|
48
|
+
- rvm: 2.7
|
42
49
|
gemfile: test/gemfiles/Gemfile.rails-edge
|
43
50
|
allow_failures:
|
44
|
-
- rvm:
|
51
|
+
- rvm: ruby-head
|
45
52
|
- gemfile: test/gemfiles/Gemfile.rails-edge
|
53
|
+
- rvm: jruby-9.2
|
54
|
+
gemfile: test/gemfiles/Gemfile.rails-4.2.x
|
55
|
+
- rvm: jruby-9.2
|
56
|
+
gemfile: test/gemfiles/Gemfile.rails-4.1.x
|
57
|
+
- rvm: jruby-9.2
|
58
|
+
gemfile: test/gemfiles/Gemfile.rails-4.0.x
|
59
|
+
- rvm: jruby-9.2
|
60
|
+
gemfile: test/gemfiles/Gemfile.rails-5.0.x.erubi
|
46
61
|
fast_finish: true
|
62
|
+
before_install:
|
63
|
+
# install older versions of rubygems and bundler only on Ruby < 2.7
|
64
|
+
- 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
|
65
|
+
- if [ `echo "${TRAVIS_RUBY_VERSION:0:3} < 2.7" | bc` == 1 ]; then gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true; fi;
|
66
|
+
- if [ `echo "${TRAVIS_RUBY_VERSION:0:3} < 2.7" | bc` == 1 ]; then gem i bundler -v '<2'; fi;
|
67
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
68
|
+
- chmod +x ./cc-test-reporter
|
69
|
+
- ./cc-test-reporter before-build
|
47
70
|
script: "bundle exec rake submodules test"
|
71
|
+
after_script:
|
72
|
+
- ./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,49 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
|
+
## 5.2
|
4
|
+
|
5
|
+
Released on September 28, 2020
|
6
|
+
([diff](https://github.com/haml/haml/compare/v5.1.2...v5.2)).
|
7
|
+
|
8
|
+
* Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](https://github.com/haml/haml/issues/972)
|
9
|
+
* 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))
|
10
|
+
* 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)
|
11
|
+
|
12
|
+
## 5.1.2
|
13
|
+
|
14
|
+
Released on August 6, 2019
|
15
|
+
([diff](https://github.com/haml/haml/compare/v5.1.1...v5.1.2)).
|
16
|
+
|
17
|
+
* 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))
|
18
|
+
|
19
|
+
## 5.1.1
|
20
|
+
|
21
|
+
Released on May 25, 2019
|
22
|
+
([diff](https://github.com/haml/haml/compare/v5.1.0...v5.1.1)).
|
23
|
+
|
24
|
+
* Fix NameError bug that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails < 5.1 + erubi. (Akira Matsuda)
|
25
|
+
|
26
|
+
## 5.1.0
|
27
|
+
|
28
|
+
Released on May 16, 2019
|
29
|
+
([diff](https://github.com/haml/haml/compare/v5.0.4...v5.1.0)).
|
30
|
+
|
31
|
+
* Rails 6 support [#1008](https://github.com/haml/haml/pull/1008) (thanks [Seb Jacobs](https://github.com/sebjacobs))
|
32
|
+
* 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))
|
33
|
+
* Fix error on empty :javascript and :css filter blocks [#986](https://github.com/haml/haml/pull/986) (thanks [Will Jordan](https://github.com/wjordan))
|
34
|
+
* Respect changes in Haml::Options.defaults in `Haml::TempleEngine` options (Takashi Kokubun)
|
35
|
+
* Un-freeze TempleEngine precompiled string literals [#983](https://github.com/haml/haml/pull/983) (thanks [Will Jordan](https://github.com/wjordan))
|
36
|
+
* 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))
|
37
|
+
* 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))
|
38
|
+
|
39
|
+
## 5.0.4
|
40
|
+
|
41
|
+
Released on October 13, 2017
|
42
|
+
([diff](https://github.com/haml/haml/compare/v5.0.3...v5.0.4)).
|
43
|
+
|
44
|
+
* Fix `haml -c --stdin` regression in 5.0.2. [#958](https://github.com/haml/haml/pull/958) (thanks [Timo Göllner](https://github.com/TeaMoe))
|
45
|
+
* Ruby 2.5 support (it wasn't working due to Ripper API change). (Akira Matsuda)
|
46
|
+
|
3
47
|
## 5.0.3
|
4
48
|
|
5
49
|
Released on September 7, 2017
|
@@ -1444,4 +1488,3 @@ has been moved to [YARD](http://yard.soen.ca).
|
|
1444
1488
|
YARD is an excellent documentation system,
|
1445
1489
|
and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
|
1446
1490
|
which is also excellent.
|
1447
|
-
>>>>>>> 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
|
[![Gem Version](https://badge.fury.io/rb/haml.svg)](http://rubygems.org/gems/haml)
|
4
|
-
[![Build Status](https://travis-ci.org/haml/haml.svg?branch=
|
5
|
-
[![Code Climate](
|
6
|
-
[![Coverage Status](http://img.shields.io/coveralls/haml/haml.svg)](https://coveralls.io/r/haml/haml)
|
4
|
+
[![Build Status](https://travis-ci.org/haml/haml.svg?branch=main)](http://travis-ci.org/haml/haml)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/haml/haml/badges/gpa.svg)](https://codeclimate.com/github/haml/haml)
|
7
6
|
[![Inline docs](http://inch-ci.org/github/haml/haml.png)](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}.
|
@@ -512,6 +517,24 @@ and is compiled to:
|
|
512
517
|
</div>
|
513
518
|
</div>
|
514
519
|
|
520
|
+
#### Class Name Merging and Ordering
|
521
|
+
|
522
|
+
Class names are ordered in the following way:
|
523
|
+
|
524
|
+
1) Tag identifiers in order (aka, ".alert.me" => "alert me")
|
525
|
+
2) Classes appearing in HTML-style attributes
|
526
|
+
3) Classes appearing in Hash-style attributes
|
527
|
+
|
528
|
+
For instance, this is a complicated and unintuitive test case illustrating the ordering
|
529
|
+
|
530
|
+
.foo.moo{:class => ['bar', 'alpha']}(class='baz')
|
531
|
+
|
532
|
+
The resulting HTML would be as follows:
|
533
|
+
|
534
|
+
<div class='foo moo baz bar alpha'></div>
|
535
|
+
|
536
|
+
*Versions of Haml prior to 5.0 would alphabetically sort class names.*
|
537
|
+
|
515
538
|
### Empty (void) Tags: `/`
|
516
539
|
|
517
540
|
The forward slash character, when placed at the end of a tag definition, causes
|
@@ -848,7 +871,7 @@ is compiled to:
|
|
848
871
|
|
849
872
|
## Ruby Evaluation
|
850
873
|
|
851
|
-
### Inserting Ruby: `=`
|
874
|
+
### Inserting Ruby: `=` {#inserting_ruby}
|
852
875
|
|
853
876
|
The equals character is followed by Ruby code. This code is evaluated and the
|
854
877
|
output is inserted into the document. For example:
|
@@ -1120,8 +1143,8 @@ is compiled to
|
|
1120
1143
|
<p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
|
1121
1144
|
</div>
|
1122
1145
|
|
1123
|
-
Note that `#{}` interpolation within filters is HTML-escaped if you specify
|
1124
|
-
{Haml::Options#
|
1146
|
+
Note that `#{}` interpolation within filters is HTML-escaped if you specify true to
|
1147
|
+
{Haml::Options#escape_filter_interpolations `:escape_filter_interpolations`} option.
|
1125
1148
|
|
1126
1149
|
The functionality of some filters such as Markdown can be provided by many
|
1127
1150
|
different libraries. Usually you don't have to worry about this - you can just
|
@@ -1318,7 +1341,7 @@ that just need a lot of template information.
|
|
1318
1341
|
So data structures and functions that require lots of arguments
|
1319
1342
|
can be wrapped over multiple lines,
|
1320
1343
|
as long as each line but the last ends in a comma
|
1321
|
-
(see [Inserting Ruby](#
|
1344
|
+
(see [Inserting Ruby](#inserting_ruby)).
|
1322
1345
|
|
1323
1346
|
## Whitespace Preservation
|
1324
1347
|
|
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
|
data/haml.gemspec
CHANGED
@@ -6,16 +6,22 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.summary = "An elegant, structured (X)HTML/XML templating engine."
|
7
7
|
spec.version = Haml::VERSION
|
8
8
|
spec.authors = ['Natalie Weizenbaum', 'Hampton Catlin', 'Norman Clarke', 'Akira Matsuda']
|
9
|
-
spec.email = ['haml@googlegroups.com', '
|
9
|
+
spec.email = ['haml@googlegroups.com', 'ronnie@dio.jp']
|
10
10
|
|
11
|
-
readmes = Dir['*'].reject{ |x| x =~ /(^|[^.a-z])[a-z]+/ || x == "TODO" }
|
12
11
|
spec.executables = ['haml']
|
13
12
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
13
|
f.match(%r{\Atest/})
|
15
14
|
end
|
16
15
|
spec.homepage = 'http://haml.info/'
|
17
|
-
spec.has_rdoc = false
|
18
16
|
spec.license = "MIT"
|
17
|
+
spec.metadata = {
|
18
|
+
"bug_tracker_uri" => "https://github.com/haml/haml/issues",
|
19
|
+
"changelog_uri" => "https://github.com/haml/haml/blob/main/CHANGELOG.md",
|
20
|
+
"documentation_uri" => "http://haml.info/docs.html",
|
21
|
+
"homepage_uri" => "http://haml.info",
|
22
|
+
"mailing_list_uri" => "https://groups.google.com/forum/?fromgroups#!forum/haml",
|
23
|
+
"source_code_uri" => "https://github.com/haml/haml"
|
24
|
+
}
|
19
25
|
|
20
26
|
spec.required_ruby_version = '>= 2.0.0'
|
21
27
|
|
@@ -26,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
26
32
|
spec.add_development_dependency 'rbench'
|
27
33
|
spec.add_development_dependency 'minitest', '>= 4.0'
|
28
34
|
spec.add_development_dependency 'nokogiri'
|
35
|
+
spec.add_development_dependency 'simplecov', '0.17.1' # Locked to this version due to https://github.com/codeclimate/test-reporter/issues/418
|
29
36
|
|
30
37
|
spec.description = <<-END
|
31
38
|
Haml (HTML Abstraction Markup Language) is a layer on top of HTML or XML that's
|
data/lib/haml.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Haml
|
3
4
|
module AttributeBuilder
|
4
5
|
# https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
@@ -35,9 +36,9 @@ module Haml
|
|
35
36
|
|
36
37
|
value =
|
37
38
|
if escape_attrs == :once
|
38
|
-
Haml::Helpers.
|
39
|
+
Haml::Helpers.escape_once_without_haml_xss(value.to_s)
|
39
40
|
elsif escape_attrs
|
40
|
-
Haml::Helpers.
|
41
|
+
Haml::Helpers.html_escape_without_haml_xss(value.to_s)
|
41
42
|
else
|
42
43
|
value.to_s
|
43
44
|
end
|
@@ -125,7 +126,7 @@ module Haml
|
|
125
126
|
elsif key == 'class'
|
126
127
|
merged_class = filter_and_join(from, ' ')
|
127
128
|
if to && merged_class
|
128
|
-
merged_class = (
|
129
|
+
merged_class = (to.split(' ') | merged_class.split(' ')).join(' ')
|
129
130
|
elsif to || merged_class
|
130
131
|
merged_class ||= to
|
131
132
|
end
|