haml 5.0.4 → 6.0.0
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/FUNDING.yml +1 -0
- data/.github/workflows/test.yml +40 -0
- data/.gitignore +16 -15
- data/CHANGELOG.md +62 -1
- data/Gemfile +18 -14
- data/MIT-LICENSE +2 -2
- data/README.md +4 -5
- data/REFERENCE.md +46 -12
- data/Rakefile +93 -103
- data/bin/bench +66 -0
- data/bin/console +11 -0
- data/bin/ruby +3 -0
- data/bin/setup +7 -0
- data/bin/stackprof +27 -0
- data/bin/test +24 -0
- data/exe/haml +6 -0
- data/ext/haml/extconf.rb +10 -0
- data/ext/haml/haml.c +537 -0
- data/ext/haml/hescape.c +108 -0
- data/ext/haml/hescape.h +20 -0
- data/haml.gemspec +39 -30
- data/lib/haml/ambles.rb +20 -0
- data/lib/haml/attribute_builder.rb +140 -128
- data/lib/haml/attribute_compiler.rb +86 -181
- data/lib/haml/attribute_parser.rb +86 -124
- data/lib/haml/cli.rb +154 -0
- data/lib/haml/compiler/children_compiler.rb +126 -0
- data/lib/haml/compiler/comment_compiler.rb +39 -0
- data/lib/haml/compiler/doctype_compiler.rb +46 -0
- data/lib/haml/compiler/script_compiler.rb +116 -0
- data/lib/haml/compiler/silent_script_compiler.rb +24 -0
- data/lib/haml/compiler/tag_compiler.rb +76 -0
- data/lib/haml/compiler.rb +64 -298
- data/lib/haml/dynamic_merger.rb +67 -0
- data/lib/haml/engine.rb +43 -219
- data/lib/haml/error.rb +29 -27
- data/lib/haml/escapable.rb +6 -42
- data/lib/haml/filters/base.rb +12 -0
- data/lib/haml/filters/cdata.rb +20 -0
- data/lib/haml/filters/coffee.rb +17 -0
- data/lib/haml/filters/css.rb +33 -0
- data/lib/haml/filters/erb.rb +10 -0
- data/lib/haml/filters/escaped.rb +22 -0
- data/lib/haml/filters/javascript.rb +33 -0
- data/lib/haml/filters/less.rb +20 -0
- data/lib/haml/filters/markdown.rb +11 -0
- data/lib/haml/filters/plain.rb +29 -0
- data/lib/haml/filters/preserve.rb +22 -0
- data/lib/haml/filters/ruby.rb +10 -0
- data/lib/haml/filters/sass.rb +15 -0
- data/lib/haml/filters/scss.rb +15 -0
- data/lib/haml/filters/text_base.rb +25 -0
- data/lib/haml/filters/tilt_base.rb +49 -0
- data/lib/haml/filters.rb +55 -378
- data/lib/haml/force_escapable.rb +29 -0
- data/lib/haml/helpers.rb +4 -696
- data/lib/haml/html.rb +22 -0
- data/lib/haml/identity.rb +13 -0
- data/lib/haml/object_ref.rb +30 -0
- data/lib/haml/parser.rb +208 -43
- data/lib/haml/rails_helpers.rb +51 -0
- data/lib/haml/rails_template.rb +55 -0
- data/lib/haml/railtie.rb +7 -40
- data/lib/haml/ruby_expression.rb +32 -0
- data/lib/haml/string_splitter.rb +20 -0
- data/lib/haml/template.rb +15 -33
- data/lib/haml/temple_line_counter.rb +2 -0
- data/lib/haml/util.rb +23 -21
- data/lib/haml/version.rb +1 -1
- data/lib/haml.rb +8 -19
- metadata +222 -50
- data/.gitmodules +0 -3
- data/.travis.yml +0 -54
- data/.yardopts +0 -23
- data/TODO +0 -24
- data/benchmark.rb +0 -66
- data/bin/haml +0 -9
- data/lib/haml/.gitattributes +0 -1
- data/lib/haml/buffer.rb +0 -235
- data/lib/haml/exec.rb +0 -348
- data/lib/haml/generator.rb +0 -41
- data/lib/haml/helpers/action_view_extensions.rb +0 -59
- data/lib/haml/helpers/action_view_mods.rb +0 -129
- data/lib/haml/helpers/action_view_xss_mods.rb +0 -59
- data/lib/haml/helpers/safe_erubi_template.rb +0 -19
- data/lib/haml/helpers/safe_erubis_template.rb +0 -32
- data/lib/haml/helpers/xss_mods.rb +0 -110
- data/lib/haml/options.rb +0 -273
- data/lib/haml/plugin.rb +0 -34
- data/lib/haml/sass_rails_filter.rb +0 -46
- data/lib/haml/template/options.rb +0 -26
- data/lib/haml/temple_engine.rb +0 -121
- data/yard/default/.gitignore +0 -1
- data/yard/default/fulldoc/html/css/common.sass +0 -15
- data/yard/default/layout/html/footer.erb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b9bc0a9bea79d404adbf4b0eb540dd256a53c4c99a71f88a2bd25b1b313685a
|
|
4
|
+
data.tar.gz: 7d76a5280aa58671b319d08776d1c93785e3ea71f9664fc40a2602f229c3a55a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d44ef26e2b98dfab93bc7e825dc6f10bc5d86c35cb094fd634b127c7da86c4512ee839cd4f0944b0c4abeac577e94d5bd032aca650a1b70d9b7c97bfeca0a34
|
|
7
|
+
data.tar.gz: 5c0c3c3689ddca67701c439d96990126663cd52b97107a3ca2fc3da38bfba5614cecbacf8049a0bc751e096370bfa4733c1cd24eb9034c21082c2215617f6b29
|
data/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: haml
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
pull_request:
|
|
7
|
+
types:
|
|
8
|
+
- opened
|
|
9
|
+
- synchronize
|
|
10
|
+
- reopened
|
|
11
|
+
schedule:
|
|
12
|
+
- cron: "00 15 * * *"
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
ruby:
|
|
19
|
+
- '2.5'
|
|
20
|
+
- '2.6'
|
|
21
|
+
- '2.7'
|
|
22
|
+
- '3.0'
|
|
23
|
+
- '3.1'
|
|
24
|
+
- jruby
|
|
25
|
+
- truffleruby-head
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v2
|
|
28
|
+
- name: Set up Ruby
|
|
29
|
+
uses: ruby/setup-ruby@v1
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
|
32
|
+
- uses: actions/cache@v2
|
|
33
|
+
with:
|
|
34
|
+
path: vendor/bundle
|
|
35
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
|
36
|
+
restore-keys: ${{ runner.os }}-gems-
|
|
37
|
+
- run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
|
|
38
|
+
- name: bundle install
|
|
39
|
+
run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
|
|
40
|
+
- run: bundle exec rake test
|
data/.gitignore
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
/.bundle/
|
|
1
2
|
/.yardoc
|
|
2
|
-
/
|
|
3
|
-
/
|
|
4
|
-
|
|
5
|
-
/
|
|
6
|
-
/
|
|
7
|
-
/
|
|
8
|
-
|
|
9
|
-
/
|
|
10
|
-
|
|
3
|
+
/Gemfile.lock
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/.idea
|
|
6
|
+
/coverage/
|
|
7
|
+
/doc/
|
|
8
|
+
/pkg/
|
|
9
|
+
/spec/reports/
|
|
10
|
+
/tmp/
|
|
11
|
+
/haml/
|
|
11
12
|
.sass-cache
|
|
12
|
-
.rbenv-version
|
|
13
|
-
.rbx
|
|
14
13
|
.ruby-version
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
*.bundle
|
|
15
|
+
*.so
|
|
16
|
+
*.su
|
|
17
|
+
*.a
|
|
18
|
+
*.o
|
|
19
|
+
*.swp
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# Haml Changelog
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
Released on September 21, 2022
|
|
6
|
+
([diff](https://github.com/haml/haml/compare/v5.2.2...v6.0.0)).
|
|
7
|
+
|
|
8
|
+
* Replace the implementation with Hamlit
|
|
9
|
+
* Haml 6 is about 1.7x faster than Haml 5 in [this benchmark](benchmark/slim/run-benchmarks.rb).
|
|
10
|
+
* The parser is kept as is, but everything else is replaced.
|
|
11
|
+
* The `haml` CLI interface was also replaced.
|
|
12
|
+
* All Haml helpers except for `preserve` are removed.
|
|
13
|
+
* Some legacy Rails integration is removed.
|
|
14
|
+
|
|
15
|
+
## 5.2.2
|
|
16
|
+
|
|
17
|
+
Released on July 27, 2021
|
|
18
|
+
([diff](https://github.com/haml/haml/compare/v5.2.1...v5.2.2)).
|
|
19
|
+
|
|
20
|
+
* Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
|
|
21
|
+
|
|
22
|
+
## 5.2.1
|
|
23
|
+
|
|
24
|
+
Released on November 30, 2020
|
|
25
|
+
([diff](https://github.com/haml/haml/compare/v5.2.0...v5.2.1)).
|
|
26
|
+
|
|
27
|
+
* Add in improved "multiline" support for attributes [#1043](https://github.com/haml/haml/issues/1043)
|
|
28
|
+
|
|
29
|
+
## 5.2
|
|
30
|
+
|
|
31
|
+
Released on September 28, 2020
|
|
32
|
+
([diff](https://github.com/haml/haml/compare/v5.1.2...v5.2.0)).
|
|
33
|
+
|
|
34
|
+
* Fix crash in the attribute optimizer when `#inspect` is overridden in TrueClass / FalseClass [#972](https://github.com/haml/haml/issues/972)
|
|
35
|
+
* 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))
|
|
36
|
+
* 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)
|
|
37
|
+
|
|
38
|
+
## 5.1.2
|
|
39
|
+
|
|
40
|
+
Released on August 6, 2019
|
|
41
|
+
([diff](https://github.com/haml/haml/compare/v5.1.1...v5.1.2)).
|
|
42
|
+
|
|
43
|
+
* 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))
|
|
44
|
+
|
|
45
|
+
## 5.1.1
|
|
46
|
+
|
|
47
|
+
Released on May 25, 2019
|
|
48
|
+
([diff](https://github.com/haml/haml/compare/v5.1.0...v5.1.1)).
|
|
49
|
+
|
|
50
|
+
* Fix NameError bug that happens on ruby 2.6.1-2.6.3 + haml 5.1.0 + rails < 5.1 + erubi. (Akira Matsuda)
|
|
51
|
+
|
|
52
|
+
## 5.1.0
|
|
53
|
+
|
|
54
|
+
Released on May 16, 2019
|
|
55
|
+
([diff](https://github.com/haml/haml/compare/v5.0.4...v5.1.0)).
|
|
56
|
+
|
|
57
|
+
* Rails 6 support [#1008](https://github.com/haml/haml/pull/1008) (thanks [Seb Jacobs](https://github.com/sebjacobs))
|
|
58
|
+
* 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))
|
|
59
|
+
* Fix error on empty :javascript and :css filter blocks [#986](https://github.com/haml/haml/pull/986) (thanks [Will Jordan](https://github.com/wjordan))
|
|
60
|
+
* Respect changes in Haml::Options.defaults in `Haml::TempleEngine` options (Takashi Kokubun)
|
|
61
|
+
* Un-freeze TempleEngine precompiled string literals [#983](https://github.com/haml/haml/pull/983) (thanks [Will Jordan](https://github.com/wjordan))
|
|
62
|
+
* 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))
|
|
63
|
+
* 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))
|
|
64
|
+
|
|
3
65
|
## 5.0.4
|
|
4
66
|
|
|
5
67
|
Released on October 13, 2017
|
|
@@ -1452,4 +1514,3 @@ has been moved to [YARD](http://yard.soen.ca).
|
|
|
1452
1514
|
YARD is an excellent documentation system,
|
|
1453
1515
|
and allows us to write our documentation in [Maruku](http://maruku.rubyforge.org),
|
|
1454
1516
|
which is also excellent.
|
|
1455
|
-
>>>>>>> External Changes
|
data/Gemfile
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
source
|
|
2
|
-
gemspec
|
|
3
|
-
|
|
4
|
-
gem "m"
|
|
5
|
-
gem "pry"
|
|
1
|
+
source 'https://rubygems.org'
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
gem "sass"
|
|
3
|
+
git_source(:github) do |repo_name|
|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
|
5
|
+
"https://github.com/#{repo_name}.git"
|
|
11
6
|
end
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
# Specify your gem's dependencies in haml.gemspec
|
|
9
|
+
gemspec
|
|
10
|
+
|
|
11
|
+
gem 'benchmark-ips', '2.3.0'
|
|
12
|
+
gem 'maxitest'
|
|
13
|
+
gem 'pry'
|
|
14
|
+
|
|
15
|
+
if /java/ === RUBY_PLATFORM # JRuby
|
|
16
|
+
gem 'pandoc-ruby'
|
|
17
|
+
else
|
|
18
|
+
gem 'redcarpet'
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
|
|
21
|
+
gem 'stackprof'
|
|
22
|
+
end
|
|
19
23
|
end
|
data/MIT-LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2006-
|
|
1
|
+
Copyright (c) 2006-2021 Hampton Catlin, Natalie Weizenbaum and Takashi Kokubun
|
|
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
|
@@ -107,13 +107,25 @@ output.
|
|
|
107
107
|
In Rails, options can be set by setting the {Haml::Template#options Haml::Template.options}
|
|
108
108
|
hash in an initializer:
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
```ruby
|
|
111
|
+
# config/initializers/haml.rb
|
|
112
|
+
Haml::Template.options[:format] = :html5
|
|
113
|
+
|
|
114
|
+
# Avoid escaping attributes which are already escaped
|
|
115
|
+
Haml::Template.options[:escape_attrs] = :once
|
|
116
|
+
```
|
|
112
117
|
|
|
113
118
|
Outside Rails, you can set them by configuring them globally in
|
|
114
119
|
Haml::Options.defaults:
|
|
115
120
|
|
|
116
|
-
|
|
121
|
+
```ruby
|
|
122
|
+
Haml::Options.defaults[:format] = :html5
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
In sinatra specifically, you can set them in global config with:
|
|
126
|
+
```ruby
|
|
127
|
+
set :haml, { escape_html: true }
|
|
128
|
+
```
|
|
117
129
|
|
|
118
130
|
Finally, you can also set them by passing an options hash to
|
|
119
131
|
{Haml::Engine#initialize}. For the complete list of available options, please
|
|
@@ -223,15 +235,19 @@ is compiled to:
|
|
|
223
235
|
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'></html>
|
|
224
236
|
|
|
225
237
|
Attribute hashes can also be stretched out over multiple lines to accommodate
|
|
226
|
-
many attributes.
|
|
227
|
-
For example:
|
|
238
|
+
many attributes.
|
|
228
239
|
|
|
229
|
-
%script{
|
|
230
|
-
|
|
240
|
+
%script{
|
|
241
|
+
"type": text/javascript",
|
|
242
|
+
"src": javascripts/script_#{2 + 7}",
|
|
243
|
+
"data": {
|
|
244
|
+
"controller": "reporter",
|
|
245
|
+
},
|
|
246
|
+
}
|
|
231
247
|
|
|
232
248
|
is compiled to:
|
|
233
249
|
|
|
234
|
-
<script src='javascripts/script_9' type='text/javascript'></script>
|
|
250
|
+
<script src='javascripts/script_9' type='text/javascript' data-controller='reporter'></script>
|
|
235
251
|
|
|
236
252
|
#### `:class` and `:id` Attributes {#class-and-id-attributes}
|
|
237
253
|
|
|
@@ -512,6 +528,24 @@ and is compiled to:
|
|
|
512
528
|
</div>
|
|
513
529
|
</div>
|
|
514
530
|
|
|
531
|
+
#### Class Name Merging and Ordering
|
|
532
|
+
|
|
533
|
+
Class names are ordered in the following way:
|
|
534
|
+
|
|
535
|
+
1) Tag identifiers in order (aka, ".alert.me" => "alert me")
|
|
536
|
+
2) Classes appearing in HTML-style attributes
|
|
537
|
+
3) Classes appearing in Hash-style attributes
|
|
538
|
+
|
|
539
|
+
For instance, this is a complicated and unintuitive test case illustrating the ordering
|
|
540
|
+
|
|
541
|
+
.foo.moo{:class => ['bar', 'alpha']}(class='baz')
|
|
542
|
+
|
|
543
|
+
The resulting HTML would be as follows:
|
|
544
|
+
|
|
545
|
+
<div class='foo moo baz bar alpha'></div>
|
|
546
|
+
|
|
547
|
+
*Versions of Haml prior to 5.0 would alphabetically sort class names.*
|
|
548
|
+
|
|
515
549
|
### Empty (void) Tags: `/`
|
|
516
550
|
|
|
517
551
|
The forward slash character, when placed at the end of a tag definition, causes
|
|
@@ -848,7 +882,7 @@ is compiled to:
|
|
|
848
882
|
|
|
849
883
|
## Ruby Evaluation
|
|
850
884
|
|
|
851
|
-
### Inserting Ruby: `=`
|
|
885
|
+
### Inserting Ruby: `=` {#inserting_ruby}
|
|
852
886
|
|
|
853
887
|
The equals character is followed by Ruby code. This code is evaluated and the
|
|
854
888
|
output is inserted into the document. For example:
|
|
@@ -1120,8 +1154,8 @@ is compiled to
|
|
|
1120
1154
|
<p>I <strong>really</strong> prefer <em>raspberry</em> jam.</p>
|
|
1121
1155
|
</div>
|
|
1122
1156
|
|
|
1123
|
-
Note that `#{}` interpolation within filters is HTML-escaped if you specify
|
|
1124
|
-
{Haml::Options#
|
|
1157
|
+
Note that `#{}` interpolation within filters is HTML-escaped if you specify true to
|
|
1158
|
+
{Haml::Options#escape_filter_interpolations `:escape_filter_interpolations`} option.
|
|
1125
1159
|
|
|
1126
1160
|
The functionality of some filters such as Markdown can be provided by many
|
|
1127
1161
|
different libraries. Usually you don't have to worry about this - you can just
|
|
@@ -1318,7 +1352,7 @@ that just need a lot of template information.
|
|
|
1318
1352
|
So data structures and functions that require lots of arguments
|
|
1319
1353
|
can be wrapped over multiple lines,
|
|
1320
1354
|
as long as each line but the last ends in a comma
|
|
1321
|
-
(see [Inserting Ruby](#
|
|
1355
|
+
(see [Inserting Ruby](#inserting_ruby)).
|
|
1322
1356
|
|
|
1323
1357
|
## Whitespace Preservation
|
|
1324
1358
|
|
data/Rakefile
CHANGED
|
@@ -1,126 +1,116 @@
|
|
|
1
|
-
require
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
t.libs << 'test'
|
|
17
|
-
t.test_files = Dir['test/*_test.rb'] + Dir['test/haml-spec/*_test.rb'] - isolated_test.file_list
|
|
18
|
-
t.warning = true
|
|
19
|
-
t.verbose = true
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Prepend DevKit into compilation phase
|
|
5
|
+
#
|
|
6
|
+
if Gem.win_platform?
|
|
7
|
+
desc 'Activates DevKit'
|
|
8
|
+
task :devkit do
|
|
9
|
+
begin
|
|
10
|
+
require 'devkit'
|
|
11
|
+
rescue LoadError
|
|
12
|
+
abort 'Failed to load DevKit required for compilation'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
task compile: :devkit
|
|
20
16
|
end
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
require 'rake/testtask'
|
|
19
|
+
if /java/ === RUBY_PLATFORM
|
|
20
|
+
# require 'rake/javaextensiontask'
|
|
21
|
+
# Rake::JavaExtensionTask.new(:haml) do |ext|
|
|
22
|
+
# ext.ext_dir = 'ext/java'
|
|
23
|
+
# ext.lib_dir = 'lib/haml'
|
|
24
|
+
# end
|
|
28
25
|
|
|
29
|
-
task :
|
|
30
|
-
|
|
26
|
+
task :compile do
|
|
27
|
+
# dummy for now
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
require 'rake/extensiontask'
|
|
31
|
+
Rake::ExtensionTask.new(:haml) do |ext|
|
|
32
|
+
ext.lib_dir = 'lib/haml'
|
|
33
|
+
end
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
task :coverage => [:set_coverage_env, :test]
|
|
36
|
+
Dir['benchmark/*.rake'].each { |b| import(b) }
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
namespace :haml do
|
|
39
|
+
Rake::TestTask.new do |t|
|
|
40
|
+
t.libs << 'lib' << 'test'
|
|
41
|
+
files = Dir['test/haml/*_test.rb']
|
|
42
|
+
files << 'test/haml/haml-spec/*_test.rb'
|
|
43
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
44
|
+
t.test_files = files
|
|
45
|
+
t.verbose = true
|
|
40
46
|
end
|
|
41
47
|
end
|
|
42
48
|
|
|
43
|
-
namespace :
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
desc "List all undocumented methods and classes."
|
|
54
|
-
task :undocumented do
|
|
55
|
-
command = 'yard --list --query '
|
|
56
|
-
command << '"object.docstring.blank? && '
|
|
57
|
-
command << '!(object.type == :method && object.is_alias?)"'
|
|
58
|
-
sh command
|
|
49
|
+
namespace :hamlit do
|
|
50
|
+
Rake::TestTask.new do |t|
|
|
51
|
+
t.libs << 'lib' << 'test'
|
|
52
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
53
|
+
t.test_files = Dir['test/hamlit/**/*_test.rb']
|
|
54
|
+
t.verbose = true
|
|
59
55
|
end
|
|
60
56
|
end
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
OUTPUT=str sets the ruby-prof output format.
|
|
73
|
-
Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
|
|
74
|
-
END
|
|
75
|
-
task :profile do
|
|
76
|
-
times = (ENV['TIMES'] || '1000').to_i
|
|
77
|
-
file = ENV['FILE'] || 'test/templates/standard.haml'
|
|
78
|
-
|
|
79
|
-
require 'bundler/setup'
|
|
80
|
-
require 'ruby-prof'
|
|
81
|
-
require 'haml'
|
|
82
|
-
file = File.read(File.expand_path("../#{file}", __FILE__))
|
|
83
|
-
obj = Object.new
|
|
84
|
-
Haml::Engine.new(file).def_method(obj, :render)
|
|
85
|
-
result = RubyProf.profile { times.times { obj.render } }
|
|
58
|
+
namespace :test do
|
|
59
|
+
Rake::TestTask.new(:all) do |t|
|
|
60
|
+
t.libs << 'lib' << 'test'
|
|
61
|
+
files = Dir['test/hamlit/**/*_test.rb']
|
|
62
|
+
files += Dir['test/haml/*_test.rb']
|
|
63
|
+
files << 'test/haml/haml-spec/*_test.rb'
|
|
64
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
65
|
+
t.test_files = files
|
|
66
|
+
t.verbose = true
|
|
67
|
+
end
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
Rake::TestTask.new(:spec) do |t|
|
|
70
|
+
t.libs << 'lib' << 'test'
|
|
71
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
72
|
+
t.test_files = %w[test/haml/haml-spec/ugly_test.rb test/haml/haml-spec/pretty_test.rb]
|
|
73
|
+
t.verbose = true
|
|
74
|
+
end
|
|
89
75
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
Rake::TestTask.new(:engine) do |t|
|
|
77
|
+
t.libs << 'lib' << 'test'
|
|
78
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
79
|
+
t.test_files = %w[test/haml/engine_test.rb]
|
|
80
|
+
t.verbose = true
|
|
95
81
|
end
|
|
96
|
-
end
|
|
97
82
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
yield
|
|
104
|
-
end
|
|
83
|
+
Rake::TestTask.new(:filters) do |t|
|
|
84
|
+
t.libs << 'lib' << 'test'
|
|
85
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
86
|
+
t.test_files = %w[test/haml/filters_test.rb]
|
|
87
|
+
t.verbose = true
|
|
105
88
|
end
|
|
106
|
-
end
|
|
107
89
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
Rake::TestTask.new(:helper) do |t|
|
|
91
|
+
t.libs << 'lib' << 'test'
|
|
92
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
93
|
+
t.test_files = %w[test/haml/helper_test.rb]
|
|
94
|
+
t.verbose = true
|
|
95
|
+
end
|
|
114
96
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
Rake::TestTask.new(:template) do |t|
|
|
98
|
+
t.libs << 'lib' << 'test'
|
|
99
|
+
t.ruby_opts = %w[-rtest_helper]
|
|
100
|
+
t.test_files = %w[test/haml/template_test.rb]
|
|
101
|
+
t.verbose = true
|
|
119
102
|
end
|
|
103
|
+
end
|
|
120
104
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
105
|
+
desc 'bench task for CI'
|
|
106
|
+
task bench: :compile do
|
|
107
|
+
if ENV['SLIM_BENCH'] == '1'
|
|
108
|
+
cmd = %w[bundle exec ruby benchmark/slim/run-benchmarks.rb]
|
|
109
|
+
else
|
|
110
|
+
cmd = ['bin/bench', 'bench', ('-c' if ENV['COMPILE'] == '1'), *ENV['TEMPLATE'].split(',')].compact
|
|
124
111
|
end
|
|
125
|
-
|
|
112
|
+
exit system(*cmd)
|
|
126
113
|
end
|
|
114
|
+
|
|
115
|
+
task default: %w[compile hamlit:test]
|
|
116
|
+
task test: %w[compile test:all]
|
data/bin/bench
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'haml'
|
|
5
|
+
require 'thor'
|
|
6
|
+
require 'benchmark/ips'
|
|
7
|
+
require_relative '../benchmark/utils/benchmark_ips_extension'
|
|
8
|
+
|
|
9
|
+
class Bench < Thor
|
|
10
|
+
class_option :show_template, type: :boolean, aliases: ['-t']
|
|
11
|
+
|
|
12
|
+
desc 'bench HAML', 'Benchmark haml template'
|
|
13
|
+
option :compile, type: :boolean, aliases: ['-c']
|
|
14
|
+
option :show_code, type: :boolean, aliases: ['-s']
|
|
15
|
+
def bench(*files)
|
|
16
|
+
files.each { |file| render(file) }
|
|
17
|
+
files.each { |file| compile(file) if options[:compile] }
|
|
18
|
+
files.each { |file| code(file) if options[:show_code] }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc 'compile HAML', 'Benchmark compilation'
|
|
22
|
+
def compile(file)
|
|
23
|
+
puts "#{?= * 49}\n Compilation: #{file}\n#{?= * 49}"
|
|
24
|
+
haml = File.read(file)
|
|
25
|
+
|
|
26
|
+
Benchmark.ips do |x|
|
|
27
|
+
x.report("haml v#{Haml::VERSION}") { Haml::Engine.new.call(haml) }
|
|
28
|
+
x.compare!
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
desc 'render HAML', 'Benchmark rendering'
|
|
33
|
+
def render(file)
|
|
34
|
+
puts "#{?= * 49}\n Rendering: #{file}\n#{?= * 49}"
|
|
35
|
+
haml = File.read(file)
|
|
36
|
+
puts haml + "\n" if options[:show_template]
|
|
37
|
+
object = Object.new
|
|
38
|
+
ruby_file = file.gsub(/\.haml\z/, '.rb')
|
|
39
|
+
if File.exist?(ruby_file)
|
|
40
|
+
object.instance_eval(File.read(ruby_file))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
object.instance_eval "def haml; #{Haml::Engine.new.call(haml)}; end"
|
|
44
|
+
|
|
45
|
+
Benchmark.ips do |x|
|
|
46
|
+
x.report("haml v#{Haml::VERSION}") { object.haml }
|
|
47
|
+
x.compare!
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
desc 'code HAML', 'Show compiled code'
|
|
52
|
+
def code(file)
|
|
53
|
+
haml = File.read(file)
|
|
54
|
+
puts "\n#{?= * 49}\n Haml Source: #{file}\n#{?= * 49}"
|
|
55
|
+
puts Haml::Engine.new.call(haml)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def method_missing(*args)
|
|
61
|
+
return super if args.length > 1
|
|
62
|
+
render(args.first.to_s)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
Bench.start
|
data/bin/console
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'hamlit'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
require 'pry'
|
|
11
|
+
Pry.start
|
data/bin/ruby
ADDED