hamlit 2.14.6 → 2.16.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/bench.yml +46 -0
  3. data/CHANGELOG.md +30 -1
  4. data/hamlit.gemspec +1 -1
  5. data/lib/hamlit/attribute_builder.rb +1 -1
  6. data/lib/hamlit/cli.rb +1 -0
  7. data/lib/hamlit/engine.rb +1 -0
  8. data/lib/hamlit/parser.rb +2 -0
  9. data/lib/hamlit/railtie.rb +5 -0
  10. data/lib/hamlit/version.rb +1 -1
  11. metadata +4 -37
  12. data/benchmark/boolean_attribute.haml +0 -6
  13. data/benchmark/class_attribute.haml +0 -5
  14. data/benchmark/common_attribute.haml +0 -3
  15. data/benchmark/data_attribute.haml +0 -4
  16. data/benchmark/dynamic_attributes/boolean_attribute.haml +0 -4
  17. data/benchmark/dynamic_attributes/class_attribute.haml +0 -4
  18. data/benchmark/dynamic_attributes/common_attribute.haml +0 -2
  19. data/benchmark/dynamic_attributes/data_attribute.haml +0 -2
  20. data/benchmark/dynamic_attributes/id_attribute.haml +0 -2
  21. data/benchmark/dynamic_boolean_attribute.haml +0 -4
  22. data/benchmark/dynamic_merger/benchmark.rb +0 -25
  23. data/benchmark/dynamic_merger/hello.haml +0 -50
  24. data/benchmark/dynamic_merger/hello.string +0 -50
  25. data/benchmark/etc/attribute_builder.haml +0 -5
  26. data/benchmark/etc/real_sample.haml +0 -888
  27. data/benchmark/etc/real_sample.rb +0 -11
  28. data/benchmark/etc/static_analyzer.haml +0 -1
  29. data/benchmark/etc/string_interpolation.haml +0 -2
  30. data/benchmark/etc/tags.haml +0 -3
  31. data/benchmark/etc/tags_loop.haml +0 -2
  32. data/benchmark/ext/build_data.rb +0 -17
  33. data/benchmark/ext/build_id.rb +0 -13
  34. data/benchmark/graph/graph.key +0 -0
  35. data/benchmark/graph/graph.png +0 -0
  36. data/benchmark/id_attribute.haml +0 -3
  37. data/benchmark/plain.haml +0 -4
  38. data/benchmark/script.haml +0 -4
  39. data/benchmark/slim/LICENSE +0 -21
  40. data/benchmark/slim/context.rb +0 -11
  41. data/benchmark/slim/run-benchmarks.rb +0 -94
  42. data/benchmark/slim/view.erb +0 -23
  43. data/benchmark/slim/view.haml +0 -18
  44. data/benchmark/slim/view.slim +0 -17
  45. data/benchmark/utils/benchmark_ips_extension.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaa5616456f4832b624f5739bce6f281235a2a758e4189d454ef080684c96452
4
- data.tar.gz: 40315c6d81b7129a7f3810378618d277a82e47596e2a6b4b615bbd31c96c2840
3
+ metadata.gz: de464e04c0b09e109a52ccae59ad85ee2a07875eaf903d8d0208d8b4d24b3d7d
4
+ data.tar.gz: a495ef4fc7e65d0e51a3538146a099d3c313b987fe11a03ef4da2468e2cabe5c
5
5
  SHA512:
6
- metadata.gz: fc4ac5b8673f3dfc68eb048f896caa239d91af799318e2037896631bb287d92cc14f10b65b5fe2a5f5fee2c5eec45d4543c9b8f4ff6b5829c8ddb379ea528f44
7
- data.tar.gz: 5874679be120e5a5e9ca359dfffe91c3ef7ce1f936984457494bebf11df3007f4c135d7be083aaca3e0f09f126aefa91f7d6270c4a0dbf038fe7fac628a6fe14
6
+ metadata.gz: 22f7bd667c39909360a6405768b71b30769d5ea3aeff02e067f48a05ee89c07dda6e2d5467eafb4f000233ece666704483e31e325bda0cb16e53cb88beb97668
7
+ data.tar.gz: 83d3434d5953eebc388eeebddbf10f76d07dece448cacb00f96bfe0da80b8488fbc311002f81cc455ccdb5586ad70a21fd76497927fe656b586e2bcfde2b3bc1
@@ -0,0 +1,46 @@
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
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ include:
20
+ - slim: 1
21
+ - template: 'benchmark/boolean_attribute.haml,benchmark/class_attribute.haml,benchmark/id_attribute.haml,benchmark/data_attribute.haml,benchmark/common_attribute.haml'
22
+ - template: 'benchmark/dynamic_attributes/boolean_attribute.haml,benchmark/dynamic_attributes/class_attribute.haml,benchmark/dynamic_attributes/id_attribute.haml,benchmark/dynamic_attributes/data_attribute.haml,benchmark/dynamic_attributes/common_attribute.haml'
23
+ - template: 'benchmark/etc/attribute_builder.haml'
24
+ - template: 'benchmark/etc/static_analyzer.haml'
25
+ - template: 'benchmark/etc/string_interpolation.haml'
26
+ - template: 'test/haml/templates/standard.haml'
27
+ compile: 1
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - name: Set up Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: '3.0'
34
+ - uses: actions/cache@v2
35
+ with:
36
+ path: vendor/bundle
37
+ key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
38
+ restore-keys: ${{ runner.os }}-gems-
39
+ - run: sudo apt-get update && sudo apt-get install -y nodejs libxslt-dev # nodejs for execjs, libxslt for TruffleRuby nokogiri
40
+ - name: bundle install
41
+ run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
42
+ - run: bundle exec rake bench
43
+ env:
44
+ SLIM_BENCH: ${{ matrix.slim }}
45
+ TEMPLATE: ${{ matrix.template }}
46
+ COMPILE: ${{ matrix.compile }}
data/CHANGELOG.md CHANGED
@@ -4,7 +4,36 @@ 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
- ## [2.14.6](https://github.com/k0kubun/hamlit/compare/v2.14.4...v2.14.5) - 2021-03-23
7
+ ## [2.16.0](https://github.com/k0kubun/hamlit/compare/v2.15.2...v2.16.0) - 2022-02-03
8
+
9
+ ### Added
10
+
11
+ - Raise an exception on a Haml-level syntax error with `hamlit compile -c`
12
+ [#189](https://github.com/k0kubun/hamlit/issues/189)
13
+ *Thanks to @dlwr*
14
+
15
+ ## [2.15.2](https://github.com/k0kubun/hamlit/compare/v2.15.1...v2.15.2) - 2022-01-04
16
+
17
+ ### Fixed
18
+
19
+ - Consider `playsinline` a boolean attribute [#187](https://github.com/k0kubun/hamlit/issues/187)
20
+ *Thanks to @ghiculescu*
21
+
22
+ ## [2.15.1](https://github.com/k0kubun/hamlit/compare/v2.15.0...v2.15.1) - 2021-07-23
23
+
24
+ ### Fixed
25
+
26
+ - Remove `benchmark` from the gem package to reduce its size [#186](https://github.com/k0kubun/hamlit/issues/186)
27
+ *Thanks to @pocke*
28
+
29
+ ## [2.15.0](https://github.com/k0kubun/hamlit/compare/v2.14.6...v2.15.0) - 2021-04-12
30
+
31
+ ### Added
32
+
33
+ - Always use Hamlit when both haml.gem and hamlit.gem are installed in Rails
34
+ *Thanks to @igor-drozdov*
35
+
36
+ ## [2.14.6](https://github.com/k0kubun/hamlit/compare/v2.14.5...v2.14.6) - 2021-03-23
8
37
 
9
38
  ### Fixed
10
39
 
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']
@@ -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
@@ -106,6 +106,7 @@ module Hamlit
106
106
  Hamlit::Engine.options.to_h.merge(
107
107
  escape_attrs: options[:escape_attrs],
108
108
  escape_html: options[:escape_html],
109
+ check_syntax: options[:check],
109
110
  )
110
111
  end
111
112
 
data/lib/hamlit/engine.rb CHANGED
@@ -21,6 +21,7 @@ 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,
24
25
  )
25
26
 
26
27
  use Parser
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
 
@@ -4,6 +4,11 @@ require 'rails'
4
4
  module Hamlit
5
5
  class Railtie < ::Rails::Railtie
6
6
  initializer :hamlit, before: :load_config_initializers do |app|
7
+ # Load haml/plugin first to override if available
8
+ begin
9
+ require 'haml/plugin'
10
+ rescue LoadError
11
+ end
7
12
  require 'hamlit/rails_template'
8
13
  end
9
14
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hamlit
3
- VERSION = '2.14.6'
3
+ VERSION = '2.16.0'
4
4
  end
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: 2.14.6
4
+ version: 2.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-24 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple
@@ -258,6 +258,7 @@ extensions:
258
258
  extra_rdoc_files: []
259
259
  files:
260
260
  - ".github/FUNDING.yml"
261
+ - ".github/workflows/bench.yml"
261
262
  - ".github/workflows/test.yml"
262
263
  - ".gitignore"
263
264
  - CHANGELOG.md
@@ -266,40 +267,6 @@ files:
266
267
  - README.md
267
268
  - REFERENCE.md
268
269
  - 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
270
  - bin/bench
304
271
  - bin/console
305
272
  - bin/ruby
@@ -393,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
360
  - !ruby/object:Gem::Version
394
361
  version: '0'
395
362
  requirements: []
396
- rubygems_version: 3.2.3
363
+ rubygems_version: 3.2.22
397
364
  signing_key:
398
365
  specification_version: 4
399
366
  summary: High Performance Haml Implementation
@@ -1,6 +0,0 @@
1
- %input{ disabled: false }
2
- %input{ disabled: true }
3
- - disabled = false
4
- %input{ disabled: disabled }
5
- - disabled = true
6
- %input{ disabled: disabled }
@@ -1,5 +0,0 @@
1
- .book{ class: 'content active' }
2
- .book(class='content active')
3
-
4
- - klass = %w[content active]
5
- .book{ class: klass }
@@ -1,3 +0,0 @@
1
- %a{ href: '&"\'<>' }
2
- - href = '&"\'<>'
3
- %a{ href: href }
@@ -1,4 +0,0 @@
1
- %div{ data: { disabled: false } }
2
- %div{ data: { disabled: true } }
3
- - hash = { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 }
4
- %div{ data: hash } data
@@ -1,4 +0,0 @@
1
- - hash = { disabled: false }
2
- %input{ hash }
3
- - hash = { disabled: true }
4
- %input{ hash }
@@ -1,4 +0,0 @@
1
- - hash = { class: %w[content active] }
2
- .book{ hash }
3
- - arr = %w[foo bar]
4
- .book(class=arr){ hash }
@@ -1,2 +0,0 @@
1
- - hash = { href: '&"\'<>' }
2
- %a{ hash }
@@ -1,2 +0,0 @@
1
- - hash = { data: { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 } }
2
- %div{ hash } data
@@ -1,2 +0,0 @@
1
- - hash = { id: %w[content active] }
2
- #book{ hash }
@@ -1,4 +0,0 @@
1
- - disabled = false
2
- %input{ disabled: disabled }
3
- - disabled = true
4
- %input{ disabled: disabled }
@@ -1,25 +0,0 @@
1
- # Original: https://github.com/amatsuda/string_template/blob/master/benchmark.rb
2
- require 'benchmark_driver'
3
-
4
- Benchmark.driver(repeat_count: 8) do |x|
5
- x.prelude %{
6
- require 'rails'
7
- require 'action_view'
8
- require 'string_template'
9
- StringTemplate::Railtie.run_initializers
10
- require 'hamlit'
11
- Hamlit::Railtie.run_initializers
12
- Hamlit::RailsTemplate.set_options(escape_html: false, generator: Temple::Generators::ArrayBuffer)
13
- require 'action_view/base'
14
-
15
- (view = Class.new(ActionView::Base).new(ActionView::LookupContext.new(''))).instance_variable_set(:@world, 'world!')
16
-
17
- # compile template
18
- hello = 'benchmark/dynamic_merger/hello'
19
- view.render(template: hello, handlers: 'string')
20
- view.render(template: hello, handlers: 'haml')
21
- }
22
- x.report 'string', %{ view.render(template: hello, handlers: 'string') }
23
- x.report 'hamlit', %{ view.render(template: hello, handlers: 'haml') }
24
- x.loop_count 100_000
25
- end
@@ -1,50 +0,0 @@
1
- hello, #{ @world }
2
- hello, #{ @world }
3
- hello, #{ @world }
4
- hello, #{ @world }
5
- hello, #{ @world }
6
- hello, #{ @world }
7
- hello, #{ @world }
8
- hello, #{ @world }
9
- hello, #{ @world }
10
- hello, #{ @world }
11
- hello, #{ @world }
12
- hello, #{ @world }
13
- hello, #{ @world }
14
- hello, #{ @world }
15
- hello, #{ @world }
16
- hello, #{ @world }
17
- hello, #{ @world }
18
- hello, #{ @world }
19
- hello, #{ @world }
20
- hello, #{ @world }
21
- hello, #{ @world }
22
- hello, #{ @world }
23
- hello, #{ @world }
24
- hello, #{ @world }
25
- hello, #{ @world }
26
- hello, #{ @world }
27
- hello, #{ @world }
28
- hello, #{ @world }
29
- hello, #{ @world }
30
- hello, #{ @world }
31
- hello, #{ @world }
32
- hello, #{ @world }
33
- hello, #{ @world }
34
- hello, #{ @world }
35
- hello, #{ @world }
36
- hello, #{ @world }
37
- hello, #{ @world }
38
- hello, #{ @world }
39
- hello, #{ @world }
40
- hello, #{ @world }
41
- hello, #{ @world }
42
- hello, #{ @world }
43
- hello, #{ @world }
44
- hello, #{ @world }
45
- hello, #{ @world }
46
- hello, #{ @world }
47
- hello, #{ @world }
48
- hello, #{ @world }
49
- hello, #{ @world }
50
- hello, #{ @world }
@@ -1,50 +0,0 @@
1
- hello, #{ @world }
2
- hello, #{ @world }
3
- hello, #{ @world }
4
- hello, #{ @world }
5
- hello, #{ @world }
6
- hello, #{ @world }
7
- hello, #{ @world }
8
- hello, #{ @world }
9
- hello, #{ @world }
10
- hello, #{ @world }
11
- hello, #{ @world }
12
- hello, #{ @world }
13
- hello, #{ @world }
14
- hello, #{ @world }
15
- hello, #{ @world }
16
- hello, #{ @world }
17
- hello, #{ @world }
18
- hello, #{ @world }
19
- hello, #{ @world }
20
- hello, #{ @world }
21
- hello, #{ @world }
22
- hello, #{ @world }
23
- hello, #{ @world }
24
- hello, #{ @world }
25
- hello, #{ @world }
26
- hello, #{ @world }
27
- hello, #{ @world }
28
- hello, #{ @world }
29
- hello, #{ @world }
30
- hello, #{ @world }
31
- hello, #{ @world }
32
- hello, #{ @world }
33
- hello, #{ @world }
34
- hello, #{ @world }
35
- hello, #{ @world }
36
- hello, #{ @world }
37
- hello, #{ @world }
38
- hello, #{ @world }
39
- hello, #{ @world }
40
- hello, #{ @world }
41
- hello, #{ @world }
42
- hello, #{ @world }
43
- hello, #{ @world }
44
- hello, #{ @world }
45
- hello, #{ @world }
46
- hello, #{ @world }
47
- hello, #{ @world }
48
- hello, #{ @world }
49
- hello, #{ @world }
50
- hello, #{ @world }
@@ -1,5 +0,0 @@
1
- - h = { 'user' => { id: 1234, name: 'eagletmt' }, book_id: 5432 }
2
- - c = %w[content active]
3
-
4
- %span.book{data: h, class: c}
5
- Book