hamlit 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff4644b3625c52ef89dd93a014324209d343055e7ff6d4be2bc928d701207d79
4
- data.tar.gz: fa7e502f834887ca24edcceacb0e3ac179fc926446b54149ba31e41a87d59673
3
+ metadata.gz: a2630e3f6654fd5d8810fdc99d6396fe75de14389c213593fba8df5f49fa9de9
4
+ data.tar.gz: aff43e55f4f7d211a2437e258f94b0ffb5338908b31761ee7f36cdabbd68a473
5
5
  SHA512:
6
- metadata.gz: b6d19a0e3dd9be45782fc5770cb9e8e38ba7d3c82f8b98e4d9271607135628c9582d628e31745153a0a477a56445ffd31cbcff2e5f9ed9c887485f07db9e5cba
7
- data.tar.gz: f61c4f0af81edd24249bf48315f773c4872ae8429f0c6640576185ec891fef8e0839be8555db8d7cb2d4be3397d64fd794c912f04136a3c070316176fcea82ca
6
+ metadata.gz: cdbed489a25180e8eac72da2941d54f643c88a678582bc3ca5d54945803b2ad954af516e74f6ebbda5b9b88ac05d51a6771e67ddf99eeec2fe2b98db3506073a
7
+ data.tar.gz: 6f6d9168fd3f2d0de56b7b78ba99396f7ab79e6a728a55ea2807292da5e6fe33d19bf78d779e1eefc926d96e7287304d29391adedaaa70c05f83862013f13777
@@ -13,18 +13,6 @@ on:
13
13
  jobs:
14
14
  bench:
15
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
16
  steps:
29
17
  - uses: actions/checkout@v2
30
18
  - name: Set up Ruby
@@ -40,7 +28,3 @@ jobs:
40
28
  - name: bundle install
41
29
  run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
42
30
  - 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,14 @@ 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.2](https://github.com/k0kubun/hamlit/compare/v3.0.1...v3.0.2) - 2022-10-13
8
+
9
+ ### Changed
10
+
11
+ - `Hamlit::Engine` and `Hamlit::Template` use StringBuffer instead of ArrayBuffer
12
+ - It seems more performant in many cases with recent Ruby versions.
13
+ - `Hamlit::RailsTemplate` is not affected.
14
+
7
15
  ## [3.0.1](https://github.com/k0kubun/hamlit/compare/v3.0.0...v3.0.1) - 2022-08-18
8
16
 
9
17
  ### Changed
data/Gemfile CHANGED
@@ -18,7 +18,6 @@ else
18
18
  gem 'redcarpet'
19
19
 
20
20
  if RUBY_PLATFORM !~ /mswin|mingw/ && RUBY_ENGINE != 'truffleruby'
21
- gem 'faml'
22
21
  gem 'stackprof'
23
22
  end
24
23
  end
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 [limitations](REFERENCE.md#limitations) by design for performance,
13
- Hamlit is **1.94x times faster** than original haml gem in [this benchmark](benchmark/slim/run-benchmarks.rb),
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 faster?
36
+ ### Why is Hamlit fast?
27
37
 
28
38
  #### Less string concatenation by design
29
- As written in [limitations](REFERENCE.md#limitations), Hamlit drops some not-so-important features which require
30
- works on runtime. With the optimized language design, we can reduce the string concatenation
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
- Hamlit currently supports Ruby 2.1 and higher. See [REFERENCE.md](REFERENCE.md) for detail features of Hamlit.
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
- ## Supported features
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
- if ENV['SLIM_BENCH'] == '1'
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/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::ArrayBuffer,
15
+ generator: Temple::Generators::StringBuffer,
16
16
  format: :html,
17
17
  attr_quote: "'",
18
18
  escape_html: true,
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hamlit
3
- VERSION = '3.0.1'
3
+ VERSION = '3.0.2'
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: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple
@@ -346,7 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
346
346
  - !ruby/object:Gem::Version
347
347
  version: '0'
348
348
  requirements: []
349
- rubygems_version: 3.4.0.dev
349
+ rubygems_version: 3.3.7
350
350
  signing_key:
351
351
  specification_version: 4
352
352
  summary: High Performance Haml Implementation