hamlit 2.14.4-java → 2.15.1-java

Sign up to get free protection for your applications and to get access to all the features.
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 +6 -38
  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: 62e629fef1bc222ab631aee99292c64ab9c67d8c590991c44dfa43e673214548
4
- data.tar.gz: f2aed6b260bec4896df12cfcea5aaa7a226efee73ea7a3df72a5018b8370f0a1
3
+ metadata.gz: 7ad29f71336e1e71fab1716562eb6e17dc21ab89536318f7be91e56991c42a76
4
+ data.tar.gz: 19592da7e2ab8cf613933dcd838ecea68c9b843cfd06d9ac67f31c6eec1a71a1
5
5
  SHA512:
6
- metadata.gz: a6b0808eec0c088bffe3d3cb4073bdaf875544e76795084e51fad9dec48fcd672f208fb302495464e9d2b5d265f026622b14e51a7fe49fb5189a11dc4843f477
7
- data.tar.gz: 6f0823f8141cbf3fc174c1b403d6c502c310fbe5dcaf40c421dda79424eb060532a194b41adbb021e9910d7f7a9b50dcd9acbcf8ed29e2162129e2fd8cbcea67
6
+ metadata.gz: 34de923109facf23d50039433576861f6ae669b4b37771be879bd9a11ae94f190456435256c20d3ff5ca3d47e5f97e31ecbcc4c9df3e16b53e635ae8a435e4c1
7
+ data.tar.gz: f0a89c63f0c777b1b236260d43d8e077c948dcddc477341abedd91d03f3d20d9a296a3c62de39548cc878739f65b57ccbe4196b9f6b52443e99b70c0fcb38841
@@ -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: java
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
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +256,8 @@ executables:
256
256
  extensions: []
257
257
  extra_rdoc_files: []
258
258
  files:
259
+ - ".github/FUNDING.yml"
260
+ - ".github/workflows/bench.yml"
259
261
  - ".github/workflows/test.yml"
260
262
  - ".gitignore"
261
263
  - CHANGELOG.md
@@ -264,40 +266,6 @@ files:
264
266
  - README.md
265
267
  - REFERENCE.md
266
268
  - Rakefile
267
- - benchmark/boolean_attribute.haml
268
- - benchmark/class_attribute.haml
269
- - benchmark/common_attribute.haml
270
- - benchmark/data_attribute.haml
271
- - benchmark/dynamic_attributes/boolean_attribute.haml
272
- - benchmark/dynamic_attributes/class_attribute.haml
273
- - benchmark/dynamic_attributes/common_attribute.haml
274
- - benchmark/dynamic_attributes/data_attribute.haml
275
- - benchmark/dynamic_attributes/id_attribute.haml
276
- - benchmark/dynamic_boolean_attribute.haml
277
- - benchmark/dynamic_merger/benchmark.rb
278
- - benchmark/dynamic_merger/hello.haml
279
- - benchmark/dynamic_merger/hello.string
280
- - benchmark/etc/attribute_builder.haml
281
- - benchmark/etc/real_sample.haml
282
- - benchmark/etc/real_sample.rb
283
- - benchmark/etc/static_analyzer.haml
284
- - benchmark/etc/string_interpolation.haml
285
- - benchmark/etc/tags.haml
286
- - benchmark/etc/tags_loop.haml
287
- - benchmark/ext/build_data.rb
288
- - benchmark/ext/build_id.rb
289
- - benchmark/graph/graph.key
290
- - benchmark/graph/graph.png
291
- - benchmark/id_attribute.haml
292
- - benchmark/plain.haml
293
- - benchmark/script.haml
294
- - benchmark/slim/LICENSE
295
- - benchmark/slim/context.rb
296
- - benchmark/slim/run-benchmarks.rb
297
- - benchmark/slim/view.erb
298
- - benchmark/slim/view.haml
299
- - benchmark/slim/view.slim
300
- - benchmark/utils/benchmark_ips_extension.rb
301
269
  - bin/bench
302
270
  - bin/console
303
271
  - bin/ruby
@@ -312,6 +280,7 @@ files:
312
280
  - ext/hamlit/hescape.h
313
281
  - hamlit.gemspec
314
282
  - lib/hamlit.rb
283
+ - lib/hamlit/ambles.rb
315
284
  - lib/hamlit/attribute_builder.rb
316
285
  - lib/hamlit/attribute_compiler.rb
317
286
  - lib/hamlit/attribute_parser.rb
@@ -390,8 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
359
  - !ruby/object:Gem::Version
391
360
  version: '0'
392
361
  requirements: []
393
- rubyforge_project:
394
- rubygems_version: 2.7.9
362
+ rubygems_version: 3.1.6
395
363
  signing_key:
396
364
  specification_version: 4
397
365
  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 }