hamlit 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +27 -1
- data/hamlit.gemspec +2 -2
- data/lib/hamlit/cli.rb +2 -9
- data/lib/hamlit/version.rb +1 -1
- data/spec/rails/.gitignore +1 -0
- data/spec/rails/Gemfile.lock +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c608591e758a09b03e878bbb4ed5c898760ddc63
|
4
|
+
data.tar.gz: c9edfe8d87f77024274a75a1f973ff120e19a31b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eefd1d26fdf9d8d16fd1300b3639cf72162954b6eb418d5d13b68ee0e5d254595b8940b9d77095a62b43b21d77edeb1a1bc6e1f65d018124738200b1f8e19bbc
|
7
|
+
data.tar.gz: 567cc7f104d647a1336291c6c0c4fa09ca51392914058522be76e3cd4fbef26684640adb1d8ccebba78f19f95c87f4553b0b19516ca64ead0bc1aaecf1b6ef4b
|
data/README.md
CHANGED
@@ -17,6 +17,8 @@ or just replace `gem "haml"` with `gem "hamlit"`.
|
|
17
17
|
|
18
18
|
Hamlit's rendering is **8.47x times faster** than original haml.
|
19
19
|
|
20
|
+

|
21
|
+
|
20
22
|
```
|
21
23
|
hamlit: 133922.9 i/s
|
22
24
|
erubis: 123464.1 i/s - 1.08x slower
|
@@ -33,13 +35,37 @@ is the same as [slim-template/slim](https://github.com/slim-template/slim)'s one
|
|
33
35
|
|
34
36
|
Haml's attribute parser is not so good. For example, raises syntax error for `%a{ b: '}' }`.
|
35
37
|
Hamlit's attribute parser is implemented with Ripper, which is an official lexer for Ruby,
|
36
|
-
so it
|
38
|
+
so it is able to parse such an attribute.
|
37
39
|
|
38
40
|
### Passing haml-spec
|
39
41
|
|
40
42
|
[haml/haml-spec](https://github.com/haml/haml-spec) is a basic suite of tests for Haml interpreters.
|
41
43
|
For all test cases in haml-spec, Hamlit behaves the same as Haml (ugly mode only, which is used on production).
|
42
44
|
|
45
|
+
Hamlit is used on [githubranking.com](http://githubranking.com/).
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
|
49
|
+
Basically the same as [haml](https://github.com/haml/haml).
|
50
|
+
Check out the [reference documentation](http://haml.info/docs/yardoc/file.REFERENCE.html) for details.
|
51
|
+
|
52
|
+
## Why high performance?
|
53
|
+
### Less work on runtime
|
54
|
+
Haml's rendering is very slow because generated code by haml runs many operations on runtime.
|
55
|
+
For example, Haml::Util is extended on view, attribute rendering runs even if it is a
|
56
|
+
static value and the values in attribute is sorted. All of them is achieved on runtime.
|
57
|
+
|
58
|
+
Hamlit extends ActionView beforehand, attribute rendering is done when compiled if it
|
59
|
+
is a static hash and no unnecessary operation is done on runtime.
|
60
|
+
|
61
|
+
### Temple optimizers
|
62
|
+
Hamlit is implemented with [temple](https://github.com/judofyr/temple), which is a template
|
63
|
+
engine framework for Ruby. Temple has some great optimizers for generated code. Thus generated
|
64
|
+
code by Hamlit is very fast.
|
65
|
+
|
66
|
+
Not only relying on temple optimizers, but also Hamlit's compiler cares about many cases
|
67
|
+
to optimize performance such as string interpolation.
|
68
|
+
|
43
69
|
## License
|
44
70
|
|
45
71
|
MIT License
|
data/hamlit.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Hamlit::VERSION
|
9
9
|
spec.authors = ["Takashi Kokubun"]
|
10
10
|
spec.email = ["takashikkbn@gmail.com"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{High Performance Haml Implementation}
|
12
|
+
spec.description = %q{High Performance Haml Implementation}
|
13
13
|
spec.homepage = "https://github.com/k0kubun/hamlit"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/hamlit/cli.rb
CHANGED
@@ -6,21 +6,18 @@ module Hamlit
|
|
6
6
|
IGNORED_COMPILERS = ['HTML'].freeze
|
7
7
|
|
8
8
|
desc 'render HAML', 'Render haml template'
|
9
|
-
option :ugly, type: :boolean, aliases: ['-u']
|
10
9
|
def render(file)
|
11
10
|
code = generate_code(file)
|
12
11
|
puts eval(code)
|
13
12
|
end
|
14
13
|
|
15
14
|
desc 'compile HAML', 'Show generated rendering code'
|
16
|
-
option :ugly, type: :boolean, aliases: ['-u']
|
17
15
|
def compile(file)
|
18
16
|
code = generate_code(file)
|
19
17
|
puts code
|
20
18
|
end
|
21
19
|
|
22
20
|
desc 'temple HAML', 'Show a compile result of hamlit AST'
|
23
|
-
option :ugly, type: :boolean, aliases: ['-u']
|
24
21
|
def temple(file)
|
25
22
|
pp generate_temple_ast(file)
|
26
23
|
end
|
@@ -41,7 +38,7 @@ module Hamlit
|
|
41
38
|
|
42
39
|
def generate_code(file)
|
43
40
|
template = File.read(file)
|
44
|
-
Hamlit::Engine.new
|
41
|
+
Hamlit::Engine.new.call(template)
|
45
42
|
end
|
46
43
|
|
47
44
|
def generate_temple_ast(file)
|
@@ -52,7 +49,7 @@ module Hamlit
|
|
52
49
|
|
53
50
|
template = File.read(file)
|
54
51
|
compilers.inject(template) do |exp, compiler|
|
55
|
-
Module.const_get(compiler).new
|
52
|
+
Module.const_get(compiler).new.call(exp)
|
56
53
|
end
|
57
54
|
end
|
58
55
|
|
@@ -78,10 +75,6 @@ module Hamlit
|
|
78
75
|
IGNORED_COMPILERS.map { |name| "Hamlit::#{name}" }
|
79
76
|
end
|
80
77
|
|
81
|
-
def options
|
82
|
-
symbolize_keys(super)
|
83
|
-
end
|
84
|
-
|
85
78
|
def symbolize_keys(hash)
|
86
79
|
{}.tap { |h| hash.each { |k, v| h[k.to_sym] = v } }
|
87
80
|
end
|
data/lib/hamlit/version.rb
CHANGED
data/spec/rails/.gitignore
CHANGED
data/spec/rails/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamlit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
@@ -276,7 +276,7 @@ dependencies:
|
|
276
276
|
- - ">="
|
277
277
|
- !ruby/object:Gem::Version
|
278
278
|
version: '0'
|
279
|
-
description:
|
279
|
+
description: High Performance Haml Implementation
|
280
280
|
email:
|
281
281
|
- takashikkbn@gmail.com
|
282
282
|
executables:
|
@@ -467,7 +467,7 @@ rubyforge_project:
|
|
467
467
|
rubygems_version: 2.4.5
|
468
468
|
signing_key:
|
469
469
|
specification_version: 4
|
470
|
-
summary:
|
470
|
+
summary: High Performance Haml Implementation
|
471
471
|
test_files:
|
472
472
|
- spec/Rakefile
|
473
473
|
- spec/hamlit/compilers/script_spec.rb
|