hamlit 2.14.4 → 2.15.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/workflows/bench.yml +46 -0
  4. data/CHANGELOG.md +27 -0
  5. data/hamlit.gemspec +1 -1
  6. data/lib/hamlit/ambles.rb +20 -0
  7. data/lib/hamlit/engine.rb +2 -0
  8. data/lib/hamlit/rails_template.rb +5 -0
  9. data/lib/hamlit/railtie.rb +5 -0
  10. data/lib/hamlit/version.rb +1 -1
  11. metadata +5 -36
  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: f7ba07071048a08ffc2c58df5987c6772236c1b895b9a301881d27c13311d318
4
- data.tar.gz: cde3a650bcc4d06ac8909447203f90b99460ff187140347c9e528107bc62a1bc
3
+ metadata.gz: b60ad4fa07019d3e03bc5d521d624607f4dc1740ccaf73f1cee9de9826f38618
4
+ data.tar.gz: 4d458ddca75c342e4f10f4cf8ccf8f660f0db230dcd8973f91bd37a3c5cf7ae9
5
5
  SHA512:
6
- metadata.gz: de8bf0cddb83e2fd86b7876461e0b44c46eced02dc85b6375e60c3669d31b4079a9e8142842abb9a5b09dbf806c1d7288f96fbc4000168659029b115e033c7a9
7
- data.tar.gz: 759a9899a5aaa126c10d5894294c66af62d74585f4d2eb99e4ed9813554fa7a07aade664071c529d7ebb71d72c62b87636abd9d09e3e82e77c8fb1193ee7ad8b
6
+ metadata.gz: 2bf9dda73fd3ad47f464a5c05327558f7f21afa2e5fa57e3c48ee726c3fcb93177a8fac9300889e7d42e3c5d0cc443a111fe9b2978d55504dbc92474488e0436
7
+ data.tar.gz: 06a36cc3240044789e160583742950f3c579f9de273ccb0291cd825264da2ea8821b0152ef4aef5d3f4c888c37c3c318628c23bdf60b8042af865a85812efa81
@@ -0,0 +1 @@
1
+ github: k0kubun
@@ -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,6 +4,33 @@ 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.15.1](https://github.com/k0kubun/hamlit/compare/v2.15.0...v2.15.1) - 2021-07-23
8
+
9
+ ### Fixed
10
+
11
+ - Remove `benchmark` from the gem package to reduce its size [#186](https://github.com/k0kubun/hamlit/issues/186)
12
+ *Thanks to @pocke*
13
+
14
+ ## [2.15.0](https://github.com/k0kubun/hamlit/compare/v2.14.6...v2.15.0) - 2021-04-12
15
+
16
+ ### Added
17
+
18
+ - Always use Hamlit when both haml.gem and hamlit.gem are installed in Rails
19
+ *Thanks to @igor-drozdov*
20
+
21
+ ## [2.14.6](https://github.com/k0kubun/hamlit/compare/v2.14.5...v2.14.6) - 2021-03-23
22
+
23
+ ### Fixed
24
+
25
+ - Optimize v2.14.5's implementation a little
26
+
27
+ ## [2.14.5](https://github.com/k0kubun/hamlit/compare/v2.14.4...v2.14.5) - 2021-03-23
28
+
29
+ ### Added
30
+
31
+ - Support `config.action_view.annotate_rendered_view_with_filenames = true` of Rails 6.1
32
+ *Thanks to @kirin121*
33
+
7
34
  ## [2.14.4](https://github.com/k0kubun/hamlit/compare/v2.14.3...v2.14.4) - 2021-02-01
8
35
 
9
36
  ### Fixed
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']
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Hamlit
3
+ class Ambles < Temple::Filter
4
+ define_options :preamble, :postamble
5
+
6
+ def initialize(*)
7
+ super
8
+ @preamble = options[:preamble]
9
+ @postamble = options[:postamble]
10
+ end
11
+
12
+ def call(ast)
13
+ ret = [:multi]
14
+ ret << [:static, @preamble] if @preamble
15
+ ret << ast
16
+ ret << [:static, @postamble] if @postamble
17
+ ret
18
+ end
19
+ end
20
+ end
data/lib/hamlit/engine.rb CHANGED
@@ -6,6 +6,7 @@ require 'hamlit/html'
6
6
  require 'hamlit/escapable'
7
7
  require 'hamlit/force_escapable'
8
8
  require 'hamlit/dynamic_merger'
9
+ require 'hamlit/ambles'
9
10
 
10
11
  module Hamlit
11
12
  class Engine < Temple::Engine
@@ -30,6 +31,7 @@ module Hamlit
30
31
  use Escapable
31
32
  use ForceEscapable
32
33
  filter :ControlFlow
34
+ use Ambles
33
35
  filter :MultiFlattener
34
36
  filter :StaticMerger
35
37
  use DynamicMerger
@@ -33,6 +33,11 @@ module Hamlit
33
33
  options = options.merge(format: :xhtml)
34
34
  end
35
35
 
36
+ if ActionView::Base.try(:annotate_rendered_view_with_filenames) && template.format == :html
37
+ options[:preamble] = "<!-- BEGIN #{template.short_identifier} -->\n"
38
+ options[:postamble] = "<!-- END #{template.short_identifier} -->\n"
39
+ end
40
+
36
41
  Engine.new(options).call(source)
37
42
  end
38
43
 
@@ -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.4'
3
+ VERSION = '2.15.1'
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.4
4
+ version: 2.15.1
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-02-01 00:00:00.000000000 Z
11
+ date: 2021-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple
@@ -257,6 +257,8 @@ extensions:
257
257
  - ext/hamlit/extconf.rb
258
258
  extra_rdoc_files: []
259
259
  files:
260
+ - ".github/FUNDING.yml"
261
+ - ".github/workflows/bench.yml"
260
262
  - ".github/workflows/test.yml"
261
263
  - ".gitignore"
262
264
  - CHANGELOG.md
@@ -265,40 +267,6 @@ files:
265
267
  - README.md
266
268
  - REFERENCE.md
267
269
  - Rakefile
268
- - benchmark/boolean_attribute.haml
269
- - benchmark/class_attribute.haml
270
- - benchmark/common_attribute.haml
271
- - benchmark/data_attribute.haml
272
- - benchmark/dynamic_attributes/boolean_attribute.haml
273
- - benchmark/dynamic_attributes/class_attribute.haml
274
- - benchmark/dynamic_attributes/common_attribute.haml
275
- - benchmark/dynamic_attributes/data_attribute.haml
276
- - benchmark/dynamic_attributes/id_attribute.haml
277
- - benchmark/dynamic_boolean_attribute.haml
278
- - benchmark/dynamic_merger/benchmark.rb
279
- - benchmark/dynamic_merger/hello.haml
280
- - benchmark/dynamic_merger/hello.string
281
- - benchmark/etc/attribute_builder.haml
282
- - benchmark/etc/real_sample.haml
283
- - benchmark/etc/real_sample.rb
284
- - benchmark/etc/static_analyzer.haml
285
- - benchmark/etc/string_interpolation.haml
286
- - benchmark/etc/tags.haml
287
- - benchmark/etc/tags_loop.haml
288
- - benchmark/ext/build_data.rb
289
- - benchmark/ext/build_id.rb
290
- - benchmark/graph/graph.key
291
- - benchmark/graph/graph.png
292
- - benchmark/id_attribute.haml
293
- - benchmark/plain.haml
294
- - benchmark/script.haml
295
- - benchmark/slim/LICENSE
296
- - benchmark/slim/context.rb
297
- - benchmark/slim/run-benchmarks.rb
298
- - benchmark/slim/view.erb
299
- - benchmark/slim/view.haml
300
- - benchmark/slim/view.slim
301
- - benchmark/utils/benchmark_ips_extension.rb
302
270
  - bin/bench
303
271
  - bin/console
304
272
  - bin/ruby
@@ -313,6 +281,7 @@ files:
313
281
  - ext/hamlit/hescape.h
314
282
  - hamlit.gemspec
315
283
  - lib/hamlit.rb
284
+ - lib/hamlit/ambles.rb
316
285
  - lib/hamlit/attribute_builder.rb
317
286
  - lib/hamlit/attribute_compiler.rb
318
287
  - lib/hamlit/attribute_parser.rb
@@ -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