hamlit 2.15.0 → 3.0.3
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/bench.yml +24 -0
- data/.github/workflows/test.yml +2 -8
- data/CHANGELOG.md +71 -0
- data/Gemfile +0 -1
- data/README.md +17 -40
- data/REFERENCE.md +1 -75
- data/Rakefile +1 -6
- data/bin/bench +0 -6
- data/hamlit.gemspec +1 -2
- data/lib/hamlit/attribute_builder.rb +1 -1
- data/lib/hamlit/cli.rb +1 -0
- data/lib/hamlit/compiler/script_compiler.rb +3 -2
- data/lib/hamlit/compiler.rb +1 -1
- data/lib/hamlit/engine.rb +3 -1
- data/lib/hamlit/filters/tilt_base.rb +5 -1
- data/lib/hamlit/parser.rb +2 -0
- data/lib/hamlit/rails_template.rb +5 -2
- data/lib/hamlit/version.rb +1 -1
- metadata +7 -54
- data/benchmark/boolean_attribute.haml +0 -6
- data/benchmark/class_attribute.haml +0 -5
- data/benchmark/common_attribute.haml +0 -3
- data/benchmark/data_attribute.haml +0 -4
- data/benchmark/dynamic_attributes/boolean_attribute.haml +0 -4
- data/benchmark/dynamic_attributes/class_attribute.haml +0 -4
- data/benchmark/dynamic_attributes/common_attribute.haml +0 -2
- data/benchmark/dynamic_attributes/data_attribute.haml +0 -2
- data/benchmark/dynamic_attributes/id_attribute.haml +0 -2
- data/benchmark/dynamic_boolean_attribute.haml +0 -4
- data/benchmark/dynamic_merger/benchmark.rb +0 -25
- data/benchmark/dynamic_merger/hello.haml +0 -50
- data/benchmark/dynamic_merger/hello.string +0 -50
- data/benchmark/etc/attribute_builder.haml +0 -5
- data/benchmark/etc/real_sample.haml +0 -888
- data/benchmark/etc/real_sample.rb +0 -11
- data/benchmark/etc/static_analyzer.haml +0 -1
- data/benchmark/etc/string_interpolation.haml +0 -2
- data/benchmark/etc/tags.haml +0 -3
- data/benchmark/etc/tags_loop.haml +0 -2
- data/benchmark/ext/build_data.rb +0 -17
- data/benchmark/ext/build_id.rb +0 -13
- data/benchmark/graph/graph.key +0 -0
- data/benchmark/graph/graph.png +0 -0
- data/benchmark/id_attribute.haml +0 -3
- data/benchmark/plain.haml +0 -4
- data/benchmark/script.haml +0 -4
- data/benchmark/slim/LICENSE +0 -21
- data/benchmark/slim/context.rb +0 -11
- data/benchmark/slim/run-benchmarks.rb +0 -94
- data/benchmark/slim/view.erb +0 -23
- data/benchmark/slim/view.haml +0 -18
- data/benchmark/slim/view.slim +0 -17
- data/benchmark/utils/benchmark_ips_extension.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0739d31df6aecc4a332c868e258322fb77a8e6003d5aa2c5fee02468809f009b'
|
4
|
+
data.tar.gz: 1917aeca307e771331e8e6d997ef58c90f106c2f4c002e35c4fb7fd424779db9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80000682f6fa89d6ceedd7137d3b1156bb9850707640bfdaf3330249c81251f6a036b3e175617d6e9b51e218d5f2cf12b551772c223e83bc6f7836afe260e62b
|
7
|
+
data.tar.gz: 87b2fb79433a8c593d0dbd4d0df17f28f5b5d64c250833048d4f6eddeb729c9394aa13a541cad8f2436237dd7da2a218af06910e4d9886f3a6ed7322f62d5d1a
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: bench
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
types:
|
8
|
+
- opened
|
9
|
+
- synchronize
|
10
|
+
- reopened
|
11
|
+
schedule:
|
12
|
+
- cron: "00 15 * * *" # 7:00 PST (-8), 8:00 PDT (-7)
|
13
|
+
jobs:
|
14
|
+
bench:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: '3.0'
|
23
|
+
bundler-cache: true
|
24
|
+
- run: bundle exec rake bench
|
data/.github/workflows/test.yml
CHANGED
@@ -25,16 +25,10 @@ jobs:
|
|
25
25
|
- truffleruby-head
|
26
26
|
steps:
|
27
27
|
- uses: actions/checkout@v2
|
28
|
+
- run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
|
28
29
|
- name: Set up Ruby
|
29
30
|
uses: ruby/setup-ruby@v1
|
30
31
|
with:
|
31
32
|
ruby-version: ${{ matrix.ruby }}
|
32
|
-
|
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
|
33
|
+
bundler-cache: true
|
40
34
|
- run: bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,77 @@ All notable changes to this project will be documented in this file. This
|
|
4
4
|
project adheres to [Semantic Versioning](http://semver.org/). This change log is based upon
|
5
5
|
[keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog).
|
6
6
|
|
7
|
+
## [3.0.3](https://github.com/k0kubun/hamlit/compare/v3.0.2...v3.0.3) - 2022-11-07
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Support sass-embedded [#196](https://github.com/k0kubun/hamlit/issues/196)
|
12
|
+
*Thanks to @ntkme*
|
13
|
+
|
14
|
+
## [3.0.2](https://github.com/k0kubun/hamlit/compare/v3.0.1...v3.0.2) - 2022-10-13
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- `Hamlit::Engine` and `Hamlit::Template` use StringBuffer instead of ArrayBuffer
|
19
|
+
- It seems more performant in many cases with recent Ruby versions.
|
20
|
+
- `Hamlit::RailsTemplate` is not affected.
|
21
|
+
|
22
|
+
## [3.0.1](https://github.com/k0kubun/hamlit/compare/v3.0.0...v3.0.1) - 2022-08-18
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- coffee-script is removed from development dependency
|
27
|
+
- It's not runtime dependency, so it shouldn't impact your application
|
28
|
+
- `:coffee` filter still works if you explicitly install coffee-script,
|
29
|
+
however, it's no longer maintained and possibly removed in the future.
|
30
|
+
|
31
|
+
## [3.0.0](https://github.com/k0kubun/hamlit/compare/v2.16.2...v3.0.0) - 2022-08-07
|
32
|
+
|
33
|
+
### Changed
|
34
|
+
|
35
|
+
- [**breaking**] Use `disable_capture: false` for non-Rails environments
|
36
|
+
- `:disable_capture` is an option introduced in v2.16.1. See its release notes for details.
|
37
|
+
- If you use Rails, it continues to use `disable_capture: true`, so you're not impacted by this change.
|
38
|
+
|
39
|
+
## [2.16.2](https://github.com/k0kubun/hamlit/compare/v2.16.1...v2.16.2) - 2022-08-07
|
40
|
+
|
41
|
+
### Fixed
|
42
|
+
|
43
|
+
- Fix an issue when `disable_capture: false` is set and a Ruby comment is put after `do`
|
44
|
+
|
45
|
+
## [2.16.1](https://github.com/k0kubun/hamlit/compare/v2.16.0...v2.16.1) - 2022-08-07
|
46
|
+
|
47
|
+
### Added
|
48
|
+
|
49
|
+
- Introduce `:disable_capture` option to capture a block
|
50
|
+
- Default: `disable_capture: true` (backward-compatible)
|
51
|
+
- For Rails, this must be `true` anyway to use Rails-native capturing.
|
52
|
+
- If you override the option like `disable_capture: false` in Hamlit::Template,
|
53
|
+
scripts starting with `=` (e.g. `= render do`) capture a block content.
|
54
|
+
- Scripts starting with `-` (e.g. `- users.each do`) are not impacted.
|
55
|
+
|
56
|
+
## [2.16.0](https://github.com/k0kubun/hamlit/compare/v2.15.2...v2.16.0) - 2022-02-03
|
57
|
+
|
58
|
+
### Added
|
59
|
+
|
60
|
+
- Raise an exception on a Haml-level syntax error with `hamlit compile -c`
|
61
|
+
[#189](https://github.com/k0kubun/hamlit/issues/189)
|
62
|
+
*Thanks to @dlwr*
|
63
|
+
|
64
|
+
## [2.15.2](https://github.com/k0kubun/hamlit/compare/v2.15.1...v2.15.2) - 2022-01-04
|
65
|
+
|
66
|
+
### Fixed
|
67
|
+
|
68
|
+
- Consider `playsinline` a boolean attribute [#187](https://github.com/k0kubun/hamlit/issues/187)
|
69
|
+
*Thanks to @ghiculescu*
|
70
|
+
|
71
|
+
## [2.15.1](https://github.com/k0kubun/hamlit/compare/v2.15.0...v2.15.1) - 2021-07-23
|
72
|
+
|
73
|
+
### Fixed
|
74
|
+
|
75
|
+
- Remove `benchmark` from the gem package to reduce its size [#186](https://github.com/k0kubun/hamlit/issues/186)
|
76
|
+
*Thanks to @pocke*
|
77
|
+
|
7
78
|
## [2.15.0](https://github.com/k0kubun/hamlit/compare/v2.14.6...v2.15.0) - 2021-04-12
|
8
79
|
|
9
80
|
### Added
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,12 +5,22 @@
|
|
5
5
|
|
6
6
|
Hamlit is a high performance [Haml](https://github.com/haml/haml) implementation.
|
7
7
|
|
8
|
+
## Project status
|
9
|
+
|
10
|
+
**Hamlit's implementation was copied to Haml 6.**
|
11
|
+
From Haml 6, you don't need to switch to Hamlit.
|
12
|
+
|
13
|
+
Both Haml 6 and Hamlit are still maintained by [@k0kubun](https://github.com/k0kubun).
|
14
|
+
While you don't need to immediately deprecate Hamlit, Haml 6 has more maintainers
|
15
|
+
and you'd better start a new project with Haml rather than Hamlit,
|
16
|
+
given no performance difference between them.
|
17
|
+
|
8
18
|
## Introduction
|
9
19
|
|
10
20
|
### What is Hamlit?
|
11
21
|
Hamlit is another implementation of [Haml](https://github.com/haml/haml).
|
12
|
-
With some [
|
13
|
-
Hamlit is **1.94x times faster** than original
|
22
|
+
With some [Hamlit's characteristics](REFERENCE.md#hamlits-characteristics) for performance,
|
23
|
+
Hamlit is **1.94x times faster** than the original Haml 5 in [this benchmark](benchmark/run-benchmarks.rb),
|
14
24
|
which is an HTML-escaped version of [slim-template/slim's one](https://github.com/slim-template/slim/blob/4.1.0/benchmarks/run-benchmarks.rb) for fairness. ([Result on Travis](https://travis-ci.org/github/k0kubun/hamlit/jobs/732178446))
|
15
25
|
|
16
26
|
<img src="https://raw.githubusercontent.com/k0kubun/hamlit/afcc2b36c4861c2f764baa09afd9530ca25eeafa/benchmark/graph/graph.png" width="600x" alt="Hamlit Benchmark" />
|
@@ -23,11 +33,12 @@ which is an HTML-escaped version of [slim-template/slim's one](https://github.co
|
|
23
33
|
haml v5.2.0: 127834.4 i/s - 1.94x slower
|
24
34
|
```
|
25
35
|
|
26
|
-
### Why is Hamlit
|
36
|
+
### Why is Hamlit fast?
|
27
37
|
|
28
38
|
#### Less string concatenation by design
|
29
|
-
As written in [
|
30
|
-
|
39
|
+
As written in [Hamlit's characteristics](REFERENCE.md#hamlits-characteristics),
|
40
|
+
Hamlit drops some not-so-important features which require works on runtime.
|
41
|
+
With the optimized language design, we can reduce the string concatenation
|
31
42
|
to build attributes.
|
32
43
|
|
33
44
|
#### Static analyzer
|
@@ -42,7 +53,7 @@ with C extension.
|
|
42
53
|
|
43
54
|
## Usage
|
44
55
|
|
45
|
-
|
56
|
+
See [REFERENCE.md](REFERENCE.md) for details.
|
46
57
|
|
47
58
|
### Rails
|
48
59
|
|
@@ -97,40 +108,6 @@ $ hamlit render in.haml
|
|
97
108
|
|
98
109
|
## Contributing
|
99
110
|
|
100
|
-
### Test latest version
|
101
|
-
|
102
|
-
```rb
|
103
|
-
# Gemfile
|
104
|
-
gem 'hamlit', github: 'k0kubun/hamlit', submodules: true
|
105
|
-
```
|
106
|
-
|
107
|
-
### Development
|
108
|
-
|
109
|
-
Contributions are welcomed. It'd be good to see
|
110
|
-
[Temple's EXPRESSIONS.md](https://github.com/judofyr/temple/blob/v0.7.6/EXPRESSIONS.md)
|
111
|
-
to learn Temple which is a template engine framework used in Hamlit.
|
112
|
-
|
113
|
-
```bash
|
114
|
-
$ git clone --recursive https://github.com/k0kubun/hamlit
|
115
|
-
$ cd hamlit
|
116
|
-
$ bundle install
|
117
|
-
|
118
|
-
# Run all tests
|
119
|
-
$ bundle exec rake test
|
120
|
-
|
121
|
-
# Run one test
|
122
|
-
$ bundle exec ruby -Ilib:test -rtest_helper test/hamlit/line_number_test.rb -l 12
|
123
|
-
|
124
|
-
# Show compiling/rendering result of some template
|
125
|
-
$ bundle exec exe/hamlit compile in.haml
|
126
|
-
$ bundle exec exe/hamlit render in.haml
|
127
|
-
|
128
|
-
# Use rails app to debug Hamlit
|
129
|
-
$ cd sample/rails
|
130
|
-
$ bundle install
|
131
|
-
$ bundle exec rails s
|
132
|
-
```
|
133
|
-
|
134
111
|
### Reporting an issue
|
135
112
|
|
136
113
|
Please report an issue with following information:
|
data/REFERENCE.md
CHANGED
@@ -5,81 +5,7 @@ See [Haml's tutorial](http://haml.info/tutorial.html) if you are not familiar wi
|
|
5
5
|
|
6
6
|
[REFERENCE - Haml Documentation](http://haml.info/docs/yardoc/file.REFERENCE.html)
|
7
7
|
|
8
|
-
##
|
9
|
-
|
10
|
-
See [Haml's reference](http://haml.info/docs/yardoc/file.REFERENCE.html)
|
11
|
-
for full features in original implementation.
|
12
|
-
|
13
|
-
- [ ] Using Haml
|
14
|
-
- [x] Rails XSS Protection
|
15
|
-
- [x] Ruby Module
|
16
|
-
- [x] Options
|
17
|
-
- [ ] Encodings
|
18
|
-
- [x] Plain Text
|
19
|
-
- [x] Escaping: \
|
20
|
-
- [ ] HTML Elements
|
21
|
-
- [x] Element Name: %
|
22
|
-
- [ ] Attributes: `
|
23
|
-
- [x] :class and :id Attributes
|
24
|
-
- [x] HTML-style Attributes: ()
|
25
|
-
- [x] Ruby 1.9-style Hashes
|
26
|
-
- [ ] Attribute Methods
|
27
|
-
- [x] Boolean Attributes
|
28
|
-
- [x] HTML5 Custom Data Attributes
|
29
|
-
- [x] Class and ID: . and #
|
30
|
-
- Implicit Div Elements
|
31
|
-
- [x] Empty (void) Tags: /
|
32
|
-
- [x] Whitespace Removal: > and <
|
33
|
-
- [x] Object Reference: []
|
34
|
-
- [x] Doctype: !!!
|
35
|
-
- [x] Comments
|
36
|
-
- [x] HTML Comments: /
|
37
|
-
- [x] Conditional Comments: /[]
|
38
|
-
- [x] Haml Comments: -#
|
39
|
-
- [x] Ruby Evaluation
|
40
|
-
- [x] Inserting Ruby: =
|
41
|
-
- [x] Running Ruby: -
|
42
|
-
- [x] Ruby Blocks
|
43
|
-
- [x] Whitespace Preservation: ~
|
44
|
-
- [x] Ruby Interpolation: #{}
|
45
|
-
- [x] Escaping HTML: &=
|
46
|
-
- [x] Unescaping HTML: !=
|
47
|
-
- [ ] Filters
|
48
|
-
- [x] :cdata
|
49
|
-
- [x] :coffee
|
50
|
-
- [x] :css
|
51
|
-
- [x] :erb
|
52
|
-
- [x] :escaped
|
53
|
-
- [x] :javascript
|
54
|
-
- [x] :less
|
55
|
-
- [x] :markdown
|
56
|
-
- [ ] :maruku
|
57
|
-
- [x] :plain
|
58
|
-
- [x] :preserve
|
59
|
-
- [x] :ruby
|
60
|
-
- `haml_io` API is not supported. Use [hamlit-haml\_io.gem](https://github.com/hamlit/hamlit-haml_io) if you need.
|
61
|
-
- [x] :sass
|
62
|
-
- [x] :scss
|
63
|
-
- [ ] :textile
|
64
|
-
- [ ] Custom Filters
|
65
|
-
- [x] Helper Methods
|
66
|
-
- [x] preserve
|
67
|
-
- [x] surround
|
68
|
-
- [x] precede
|
69
|
-
- [x] succeed
|
70
|
-
- [x] Multiline: |
|
71
|
-
- [x] Whitespace Preservation
|
72
|
-
- [ ] Helpers
|
73
|
-
|
74
|
-
|
75
|
-
## Limitations
|
76
|
-
|
77
|
-
### No Haml buffer
|
78
|
-
Hamlit uses `Array` as buffer for performance. So you can't touch Haml::Buffer from template when using Hamlit.
|
79
|
-
|
80
|
-
### Haml helpers are still in development
|
81
|
-
At the same time, because some methods in `Haml::Helpers` require `Haml::Buffer`, they are not supported now.
|
82
|
-
But some helpers are supported on Rails. Some of not-implemented methods are planned to be supported.
|
8
|
+
## Hamlit's characteristics
|
83
9
|
|
84
10
|
### Limited attributes hyphenation
|
85
11
|
In Haml, `%a{ foo: { bar: 'baz' } }` is rendered as `<a foo-bar='baz'></a>`, whatever foo is.
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'bundler/setup'
|
2
1
|
require 'bundler/gem_tasks'
|
3
2
|
|
4
3
|
#
|
@@ -105,11 +104,7 @@ end
|
|
105
104
|
|
106
105
|
desc 'bench task for CI'
|
107
106
|
task bench: :compile do
|
108
|
-
|
109
|
-
cmd = %w[bundle exec ruby benchmark/slim/run-benchmarks.rb]
|
110
|
-
else
|
111
|
-
cmd = ['bin/bench', 'bench', ('-c' if ENV['COMPILE'] == '1'), *ENV['TEMPLATE'].split(',')].compact
|
112
|
-
end
|
107
|
+
cmd = %w[bundle exec ruby benchmark/run-benchmarks.rb]
|
113
108
|
exit system(*cmd)
|
114
109
|
end
|
115
110
|
|
data/bin/bench
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
4
|
require 'hamlit'
|
5
|
-
require 'faml'
|
6
5
|
require 'thor'
|
7
6
|
require 'benchmark/ips'
|
8
7
|
require_relative '../benchmark/utils/benchmark_ips_extension'
|
@@ -26,7 +25,6 @@ class Bench < Thor
|
|
26
25
|
|
27
26
|
Benchmark.ips do |x|
|
28
27
|
x.report("haml v#{Haml::VERSION}") { Haml::Engine.new(haml, escape_html: true, escape_attrs: true).precompiled }
|
29
|
-
x.report("faml v#{Faml::VERSION}") { Faml::Engine.new.call(haml) }
|
30
28
|
x.report("hamlit v#{Hamlit::VERSION}") { Hamlit::Engine.new.call(haml) }
|
31
29
|
x.compare!
|
32
30
|
end
|
@@ -44,12 +42,10 @@ class Bench < Thor
|
|
44
42
|
end
|
45
43
|
|
46
44
|
Haml::Engine.new(haml, escape_html: true, escape_attrs: true).def_method(object, :haml)
|
47
|
-
object.instance_eval "def faml; #{Faml::Engine.new.call(haml)}; end"
|
48
45
|
object.instance_eval "def hamlit; #{Hamlit::Engine.new.call(haml)}; end"
|
49
46
|
|
50
47
|
Benchmark.ips do |x|
|
51
48
|
x.report("haml v#{Haml::VERSION}") { object.haml }
|
52
|
-
x.report("faml v#{Faml::VERSION}") { object.faml }
|
53
49
|
x.report("hamlit v#{Hamlit::VERSION}") { object.hamlit }
|
54
50
|
x.compare!
|
55
51
|
end
|
@@ -60,8 +56,6 @@ class Bench < Thor
|
|
60
56
|
haml = File.read(file)
|
61
57
|
puts "#{?= * 49}\n Haml Source: #{file}\n#{?= * 49}"
|
62
58
|
puts Haml::Engine.new(haml, escape_html: true, escape_attrs: true).precompiled
|
63
|
-
puts "\n#{?= * 49}\n Faml Source: #{file}\n#{?= * 49}"
|
64
|
-
puts Faml::Engine.new.call(haml)
|
65
59
|
puts "\n#{?= * 49}\n Hamlit Source: #{file}\n#{?= * 49}"
|
66
60
|
puts Hamlit::Engine.new.call(haml)
|
67
61
|
end
|
data/hamlit.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/k0kubun/hamlit'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample)/}) }
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample|benchmark)/}) }
|
18
18
|
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
spec.add_development_dependency 'benchmark_driver'
|
34
34
|
spec.add_development_dependency 'bundler'
|
35
|
-
spec.add_development_dependency 'coffee-script'
|
36
35
|
spec.add_development_dependency 'erubi'
|
37
36
|
spec.add_development_dependency 'haml', '>= 5'
|
38
37
|
spec.add_development_dependency 'less'
|
@@ -7,7 +7,7 @@ module Hamlit::AttributeBuilder
|
|
7
7
|
defer reversed ismap seamless muted required
|
8
8
|
autofocus novalidate formnovalidate open pubdate
|
9
9
|
itemscope allowfullscreen default inert sortable
|
10
|
-
truespeed typemustmatch download].freeze
|
10
|
+
truespeed typemustmatch download playsinline].freeze
|
11
11
|
|
12
12
|
# Java extension is not implemented for JRuby yet.
|
13
13
|
# TruffleRuby does not implement `rb_ary_sort_bang`, etc.
|
data/lib/hamlit/cli.rb
CHANGED
@@ -6,8 +6,9 @@ require 'hamlit/string_splitter'
|
|
6
6
|
module Hamlit
|
7
7
|
class Compiler
|
8
8
|
class ScriptCompiler
|
9
|
-
def initialize(identity)
|
9
|
+
def initialize(identity, options)
|
10
10
|
@identity = identity
|
11
|
+
@disable_capture = options[:disable_capture]
|
11
12
|
end
|
12
13
|
|
13
14
|
def compile(node, &block)
|
@@ -79,7 +80,7 @@ module Hamlit
|
|
79
80
|
else
|
80
81
|
[:multi,
|
81
82
|
[:block, "#{var} = #{node.value[:text]}",
|
82
|
-
[:multi, [:newline], yield(node)]
|
83
|
+
[:multi, [:newline], @disable_capture ? yield(node) : [:capture, Temple::Utils.unique_name, yield(node)]]
|
83
84
|
],
|
84
85
|
]
|
85
86
|
end
|
data/lib/hamlit/compiler.rb
CHANGED
@@ -16,7 +16,7 @@ module Hamlit
|
|
16
16
|
@comment_compiler = CommentCompiler.new
|
17
17
|
@doctype_compiler = DoctypeCompiler.new(options)
|
18
18
|
@filter_compiler = Filters.new(options)
|
19
|
-
@script_compiler = ScriptCompiler.new(identity)
|
19
|
+
@script_compiler = ScriptCompiler.new(identity, options)
|
20
20
|
@silent_script_compiler = SilentScriptCompiler.new
|
21
21
|
@tag_compiler = TagCompiler.new(identity, options)
|
22
22
|
end
|
data/lib/hamlit/engine.rb
CHANGED
@@ -12,7 +12,7 @@ module Hamlit
|
|
12
12
|
class Engine < Temple::Engine
|
13
13
|
define_options(
|
14
14
|
:buffer_class,
|
15
|
-
generator: Temple::Generators::
|
15
|
+
generator: Temple::Generators::StringBuffer,
|
16
16
|
format: :html,
|
17
17
|
attr_quote: "'",
|
18
18
|
escape_html: true,
|
@@ -21,6 +21,8 @@ module Hamlit
|
|
21
21
|
hr img input isindex keygen link menuitem meta
|
22
22
|
param source track wbr),
|
23
23
|
filename: "",
|
24
|
+
check_syntax: false,
|
25
|
+
disable_capture: false,
|
24
26
|
)
|
25
27
|
|
26
28
|
use Parser
|
@@ -7,7 +7,11 @@ module Hamlit
|
|
7
7
|
def self.render(name, source, indent_width: 0)
|
8
8
|
text = ::Tilt["t.#{name}"].new { source }.render
|
9
9
|
return text if indent_width == 0
|
10
|
-
text.
|
10
|
+
if text.frozen?
|
11
|
+
text.gsub(/^/, ' ' * indent_width)
|
12
|
+
else
|
13
|
+
text.gsub!(/^/, ' ' * indent_width)
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def explicit_require?(needed_registration)
|
data/lib/hamlit/parser.rb
CHANGED
@@ -20,6 +20,7 @@ module Hamlit
|
|
20
20
|
autoclose
|
21
21
|
escape_html
|
22
22
|
escape_attrs
|
23
|
+
check_syntax
|
23
24
|
].freeze
|
24
25
|
|
25
26
|
def initialize(options = {})
|
@@ -35,6 +36,7 @@ module Hamlit
|
|
35
36
|
end
|
36
37
|
HamlParser.new(HamlOptions.new(@options)).call(template)
|
37
38
|
rescue ::Hamlit::HamlError => e
|
39
|
+
raise e if @options[:check_syntax]
|
38
40
|
error_with_lineno(e)
|
39
41
|
end
|
40
42
|
|
@@ -15,6 +15,7 @@ module Hamlit
|
|
15
15
|
use_html_safe: true,
|
16
16
|
streaming: true,
|
17
17
|
buffer_class: 'ActionView::OutputBuffer',
|
18
|
+
disable_capture: true,
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
@@ -34,8 +35,10 @@ module Hamlit
|
|
34
35
|
end
|
35
36
|
|
36
37
|
if ActionView::Base.try(:annotate_rendered_view_with_filenames) && template.format == :html
|
37
|
-
options
|
38
|
-
|
38
|
+
options = options.merge(
|
39
|
+
preamble: "<!-- BEGIN #{template.short_identifier} -->\n",
|
40
|
+
postamble: "<!-- END #{template.short_identifier} -->\n",
|
41
|
+
)
|
39
42
|
end
|
40
43
|
|
41
44
|
Engine.new(options).call(source)
|
data/lib/hamlit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: coffee-script
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: erubi
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,6 +244,7 @@ extensions:
|
|
258
244
|
extra_rdoc_files: []
|
259
245
|
files:
|
260
246
|
- ".github/FUNDING.yml"
|
247
|
+
- ".github/workflows/bench.yml"
|
261
248
|
- ".github/workflows/test.yml"
|
262
249
|
- ".gitignore"
|
263
250
|
- CHANGELOG.md
|
@@ -266,40 +253,6 @@ files:
|
|
266
253
|
- README.md
|
267
254
|
- REFERENCE.md
|
268
255
|
- Rakefile
|
269
|
-
- benchmark/boolean_attribute.haml
|
270
|
-
- benchmark/class_attribute.haml
|
271
|
-
- benchmark/common_attribute.haml
|
272
|
-
- benchmark/data_attribute.haml
|
273
|
-
- benchmark/dynamic_attributes/boolean_attribute.haml
|
274
|
-
- benchmark/dynamic_attributes/class_attribute.haml
|
275
|
-
- benchmark/dynamic_attributes/common_attribute.haml
|
276
|
-
- benchmark/dynamic_attributes/data_attribute.haml
|
277
|
-
- benchmark/dynamic_attributes/id_attribute.haml
|
278
|
-
- benchmark/dynamic_boolean_attribute.haml
|
279
|
-
- benchmark/dynamic_merger/benchmark.rb
|
280
|
-
- benchmark/dynamic_merger/hello.haml
|
281
|
-
- benchmark/dynamic_merger/hello.string
|
282
|
-
- benchmark/etc/attribute_builder.haml
|
283
|
-
- benchmark/etc/real_sample.haml
|
284
|
-
- benchmark/etc/real_sample.rb
|
285
|
-
- benchmark/etc/static_analyzer.haml
|
286
|
-
- benchmark/etc/string_interpolation.haml
|
287
|
-
- benchmark/etc/tags.haml
|
288
|
-
- benchmark/etc/tags_loop.haml
|
289
|
-
- benchmark/ext/build_data.rb
|
290
|
-
- benchmark/ext/build_id.rb
|
291
|
-
- benchmark/graph/graph.key
|
292
|
-
- benchmark/graph/graph.png
|
293
|
-
- benchmark/id_attribute.haml
|
294
|
-
- benchmark/plain.haml
|
295
|
-
- benchmark/script.haml
|
296
|
-
- benchmark/slim/LICENSE
|
297
|
-
- benchmark/slim/context.rb
|
298
|
-
- benchmark/slim/run-benchmarks.rb
|
299
|
-
- benchmark/slim/view.erb
|
300
|
-
- benchmark/slim/view.haml
|
301
|
-
- benchmark/slim/view.slim
|
302
|
-
- benchmark/utils/benchmark_ips_extension.rb
|
303
256
|
- bin/bench
|
304
257
|
- bin/console
|
305
258
|
- bin/ruby
|
@@ -378,7 +331,7 @@ homepage: https://github.com/k0kubun/hamlit
|
|
378
331
|
licenses:
|
379
332
|
- MIT
|
380
333
|
metadata: {}
|
381
|
-
post_install_message:
|
334
|
+
post_install_message:
|
382
335
|
rdoc_options: []
|
383
336
|
require_paths:
|
384
337
|
- lib
|
@@ -393,8 +346,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
393
346
|
- !ruby/object:Gem::Version
|
394
347
|
version: '0'
|
395
348
|
requirements: []
|
396
|
-
rubygems_version: 3.
|
397
|
-
signing_key:
|
349
|
+
rubygems_version: 3.3.7
|
350
|
+
signing_key:
|
398
351
|
specification_version: 4
|
399
352
|
summary: High Performance Haml Implementation
|
400
353
|
test_files: []
|