hamlit 2.8.1 → 2.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile +5 -0
- data/README.md +8 -13
- data/REFERENCE.md +0 -6
- data/benchmark/slim/run-benchmarks.rb +5 -6
- data/hamlit.gemspec +2 -2
- data/lib/hamlit/cli.rb +8 -4
- data/lib/hamlit/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36ec14e388895690831d2699c9d2bf4f8d3c37f3
|
4
|
+
data.tar.gz: 0151505b707e2808531677275487282eb9603fea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f94ea2e429770cd4cd28879a2300bd59877b25a8ce4be65a4c87834b9ba0098a992380b1c371db466c412817c598757273f8c863f76fd4e0e1de8a50ed286fe6
|
7
|
+
data.tar.gz: f0889755f2165762003d9e5d8092b4a88f7a22cb23900f0da9f51ed4559156eae17547f5dee51fe62a80080389019c42d611aab224debe3c237ae1c345fff0cd
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ 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.8.2](https://github.com/k0kubun/hamlit/compare/v2.8.1...v2.8.2) - 2017-06-19
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Add `--no-color` option to disable coloring in `hamlit compile` command
|
12
|
+
[#111](https://github.com/k0kubun/hamlit/issues/111).
|
13
|
+
|
7
14
|
## [2.8.1](https://github.com/k0kubun/hamlit/compare/v2.8.0...v2.8.1) - 2017-04-03
|
8
15
|
|
9
16
|
### Fixed
|
@@ -11,8 +18,6 @@ project adheres to [Semantic Versioning](http://semver.org/). This change log is
|
|
11
18
|
- Fix SEGV caused by nil in old attributes
|
12
19
|
[#101](https://github.com/k0kubun/hamlit/issues/101). *Thanks to @FND*
|
13
20
|
|
14
|
-
### Fixed
|
15
|
-
|
16
21
|
## [2.8.0](https://github.com/k0kubun/hamlit/compare/v2.7.5...v2.8.0) - 2017-02-12
|
17
22
|
|
18
23
|
### Changed
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,17 +10,17 @@ Hamlit is a high performance [Haml](https://github.com/haml/haml) implementation
|
|
10
10
|
### What is Hamlit?
|
11
11
|
Hamlit is another implementation of [Haml](https://github.com/haml/haml).
|
12
12
|
With some [limitations](REFERENCE.md#limitations) by design for performance,
|
13
|
-
Hamlit is **
|
14
|
-
which is an HTML-escaped version of [slim-template/slim's one](https://github.com/slim-template/slim/blob/v3.0.
|
13
|
+
Hamlit is **2.39x times faster** than original haml gem in [this benchmark](benchmark/slim/run-benchmarks.rb),
|
14
|
+
which is an HTML-escaped version of [slim-template/slim's one](https://github.com/slim-template/slim/blob/v3.0.8/benchmarks/run-benchmarks.rb) for fairness. ([Result on Travis](https://travis-ci.org/k0kubun/hamlit/jobs/236567391))
|
15
15
|
|
16
|
-
|
16
|
+
<img src="https://i.gyazo.com/0f0c0362b6bd69f82715bec1d8caa191.png" width="600px" alt="Hamlit Benchmark"/>
|
17
17
|
|
18
18
|
```
|
19
|
-
hamlit v2.
|
20
|
-
|
21
|
-
slim v3.0.
|
22
|
-
|
23
|
-
|
19
|
+
hamlit v2.8.1: 131048.9 i/s
|
20
|
+
erubi v1.6.0: 125445.4 i/s - 1.04x slower
|
21
|
+
slim v3.0.8: 121390.4 i/s - 1.08x slower
|
22
|
+
faml v0.8.1: 100750.5 i/s - 1.30x slower
|
23
|
+
haml v5.0.1: 54882.6 i/s - 2.39x slower
|
24
24
|
```
|
25
25
|
|
26
26
|
### Why is Hamlit faster?
|
@@ -30,11 +30,6 @@ As written in [limitations](REFERENCE.md#limitations), Hamlit drops some not-so-
|
|
30
30
|
works on runtime. With the optimized language design, we can reduce the string concatenation
|
31
31
|
to build attributes.
|
32
32
|
|
33
|
-
#### Temple optimizers
|
34
|
-
Hamlit is built with [Temple](https://github.com/judofyr/temple), which is a framework to build
|
35
|
-
template engines and also used in Slim. By using the framework and its optimizers, Hamlit can
|
36
|
-
reduce string allocation and concatenation easily.
|
37
|
-
|
38
33
|
#### Static analyzer
|
39
34
|
Hamlit analyzes Ruby expressions with Ripper and render it on compilation if the expression
|
40
35
|
is static. And Hamlit can also compile string literal with string interpolation to reduce
|
data/REFERENCE.md
CHANGED
@@ -73,12 +73,6 @@ for full features in original implementation.
|
|
73
73
|
|
74
74
|
## Limitations
|
75
75
|
|
76
|
-
### No pretty mode
|
77
|
-
Haml has :pretty mode and :ugly mode. :pretty mode is used on development and indented beautifully.
|
78
|
-
On production environment, :ugly mode is used and Hamlit currently supports only this mode.
|
79
|
-
|
80
|
-
So you'll see difference rendering result on development environment, but it'll be the same on production.
|
81
|
-
|
82
76
|
### No Haml buffer
|
83
77
|
Hamlit uses `Array` as buffer for performance. So you can't touch Haml::Buffer from template when using Hamlit.
|
84
78
|
|
@@ -40,7 +40,7 @@ require 'context'
|
|
40
40
|
|
41
41
|
require 'benchmark/ips'
|
42
42
|
require 'tilt'
|
43
|
-
require '
|
43
|
+
require 'erubi'
|
44
44
|
require 'erb'
|
45
45
|
require 'haml'
|
46
46
|
require 'faml'
|
@@ -59,19 +59,18 @@ class SlimBenchmarks
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def init_compiled_benches
|
62
|
-
|
63
|
-
|
64
|
-
context = Context.new
|
62
|
+
context = Context.new
|
65
63
|
|
64
|
+
haml_ugly = Haml::Engine.new(@haml_code, format: :html5, escape_html: true)
|
66
65
|
haml_ugly.def_method(context, :run_haml_ugly)
|
67
66
|
context.instance_eval %{
|
68
|
-
def
|
67
|
+
def run_erubi; #{Erubi::Engine.new(@erb_code).src}; end
|
69
68
|
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
70
69
|
def run_faml; #{Faml::Engine.new.call @haml_code}; end
|
71
70
|
def run_hamlit; #{Hamlit::Engine.new.call @haml_code}; end
|
72
71
|
}
|
73
72
|
|
74
|
-
bench("
|
73
|
+
bench("erubi v#{Erubi::VERSION}") { context.run_erubi } unless @only_haml
|
75
74
|
bench("slim v#{Slim::VERSION}") { context.run_slim_ugly } unless @only_haml
|
76
75
|
bench("haml v#{Haml::VERSION}") { context.run_haml_ugly }
|
77
76
|
bench("faml v#{Faml::VERSION}") { context.run_faml }
|
data/hamlit.gemspec
CHANGED
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler'
|
29
29
|
spec.add_development_dependency 'coffee-script'
|
30
|
-
spec.add_development_dependency '
|
31
|
-
spec.add_development_dependency 'haml'
|
30
|
+
spec.add_development_dependency 'erubi'
|
31
|
+
spec.add_development_dependency 'haml'
|
32
32
|
spec.add_development_dependency 'less'
|
33
33
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
34
34
|
spec.add_development_dependency 'rails', '>= 4.0.0'
|
data/lib/hamlit/cli.rb
CHANGED
@@ -18,8 +18,14 @@ module Hamlit
|
|
18
18
|
|
19
19
|
desc 'compile HAML', 'Show compile result'
|
20
20
|
option :actionview, type: :boolean, default: false, aliases: %w[-a]
|
21
|
+
option :color, type: :boolean, default: false, aliases: %w[-c]
|
21
22
|
def compile(file)
|
22
|
-
|
23
|
+
code = generate_code(file)
|
24
|
+
if options[:color]
|
25
|
+
colored_puts generate_code(file)
|
26
|
+
else
|
27
|
+
puts code
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
desc 'temple HAML', 'Show temple intermediate expression'
|
@@ -95,11 +101,9 @@ module Hamlit
|
|
95
101
|
render(args.first.to_s)
|
96
102
|
end
|
97
103
|
|
98
|
-
def
|
104
|
+
def colored_puts(code)
|
99
105
|
require 'pry'
|
100
106
|
puts Pry.Code(code).highlighted
|
101
|
-
rescue LoadError
|
102
|
-
puts code
|
103
107
|
end
|
104
108
|
|
105
109
|
# Enable colored pretty printing only for development environment.
|
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: 2.8.
|
4
|
+
version: 2.8.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: 2017-
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: erubi
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: haml
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: less
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -368,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
368
368
|
version: '0'
|
369
369
|
requirements: []
|
370
370
|
rubyforge_project:
|
371
|
-
rubygems_version: 2.
|
371
|
+
rubygems_version: 2.6.11
|
372
372
|
signing_key:
|
373
373
|
specification_version: 4
|
374
374
|
summary: High Performance Haml Implementation
|