fast_haml 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/benchmark/rendering.rb +11 -5
- data/lib/fast_haml/compiler.rb +9 -4
- data/lib/fast_haml/element_parser.rb +1 -1
- data/lib/fast_haml/version.rb +1 -1
- data/spec/render/attribute_spec.rb +8 -0
- data/spec/render/script_spec.rb +7 -0
- 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: 82c2cd008b3cb7f86bf02d80ad69ae0655bd88b6
|
4
|
+
data.tar.gz: a06febaeb2ccf36598a2d612f8dd9de3e367f8c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26b7a473dd89a20eb8dcef16c14b435157ea054ae8aac72bd19782959bc8de54d010c119580f6c5bd6a1617f19e1d0b20354e2d5691a2f2428df173a52bfb0c5
|
7
|
+
data.tar.gz: 15431eb000c43add9ab90cfd19167c52a5c23f0cee9fdc56b84bbcdbd7d40b1fbbdfd12bf5ddd89df5e102f861d6621550a28d4e8d98e8a404c02d9f10d858b7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.1.6 (2015-03-11)
|
2
|
+
- Fix render error with comment-only script
|
3
|
+
- https://github.com/eagletmt/fast_haml/issues/6
|
4
|
+
- Fix parsing error at multiline attributes
|
5
|
+
- https://github.com/eagletmt/fast_haml/issues/7
|
6
|
+
|
1
7
|
## 0.1.5 (2015-03-01)
|
2
8
|
- Fix minor newline generation bug with Haml comment
|
3
9
|
|
data/benchmark/rendering.rb
CHANGED
@@ -14,15 +14,21 @@ Benchmark.ips do |x|
|
|
14
14
|
obj = Object.new
|
15
15
|
|
16
16
|
Haml::Engine.new(File.read(template), ugly: true, escape_html: true).def_method(obj, :haml)
|
17
|
-
|
18
|
-
obj.instance_eval("def
|
17
|
+
code_array = FastHaml::Engine.new.call(File.read(template))
|
18
|
+
obj.instance_eval("def fast_haml_array; #{code_array}; end")
|
19
|
+
code_string = FastHaml::Engine.new(generator: Temple::Generators::RailsOutputBuffer).call(File.read(template))
|
20
|
+
obj.instance_eval("def fast_haml_string; #{code_string}; end")
|
19
21
|
|
20
|
-
x.report('Haml
|
22
|
+
x.report('Haml') do
|
21
23
|
obj.haml
|
22
24
|
end
|
23
25
|
|
24
|
-
x.report('FastHaml
|
25
|
-
obj.
|
26
|
+
x.report('FastHaml (Array)') do
|
27
|
+
obj.fast_haml_array
|
28
|
+
end
|
29
|
+
|
30
|
+
x.report('FastHaml (String)') do
|
31
|
+
obj.fast_haml_string
|
26
32
|
end
|
27
33
|
|
28
34
|
x.compare!
|
data/lib/fast_haml/compiler.rb
CHANGED
@@ -318,10 +318,15 @@ module FastHaml
|
|
318
318
|
|
319
319
|
def compile_script(ast)
|
320
320
|
sym = unique_name
|
321
|
-
temple = [:multi
|
322
|
-
|
323
|
-
|
324
|
-
|
321
|
+
temple = [:multi]
|
322
|
+
if ast.children.empty?
|
323
|
+
temple << [:code, "#{sym} = (#{ast.script}"] << [:newline] << [:code, ')']
|
324
|
+
else
|
325
|
+
temple << [:code, "#{sym} = #{ast.script}"] << [:newline]
|
326
|
+
compile_children(ast, temple)
|
327
|
+
if !ast.mid_block_keyword
|
328
|
+
temple << [:code, 'end']
|
329
|
+
end
|
325
330
|
end
|
326
331
|
if !ast.escape_html && ast.preserve
|
327
332
|
temple << [:haml, :preserve, sym]
|
data/lib/fast_haml/version.rb
CHANGED
@@ -164,6 +164,14 @@ HAML
|
|
164
164
|
end
|
165
165
|
|
166
166
|
it 'parses multiline attribute list' do
|
167
|
+
expect(render_string(<<HAML)).to eq("<span data-bar='2' data-foo='1'>\n<span>hello</span>\n</span>\n")
|
168
|
+
%span{data: {foo: 1,
|
169
|
+
bar: 2}}
|
170
|
+
%span hello
|
171
|
+
HAML
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'parses HTML-style multiline attribute list' do
|
167
175
|
expect(render_string(<<HAML)).to eq("<span bar='3' foo='1'>hello</span>\n")
|
168
176
|
%span(foo=1
|
169
177
|
|
data/spec/render/script_spec.rb
CHANGED
@@ -34,6 +34,13 @@ HAML
|
|
34
34
|
HAML
|
35
35
|
end
|
36
36
|
|
37
|
+
it 'can be comment-only' do
|
38
|
+
expect(render_string(<<HAML)).to eq("\nstring\n")
|
39
|
+
= # comment
|
40
|
+
= 'string'
|
41
|
+
HAML
|
42
|
+
end
|
43
|
+
|
37
44
|
it 'can have children' do
|
38
45
|
expect(render_string(<<HAML)).to eq("<span>0</span>\n1<span>end</span>\n")
|
39
46
|
= 1.times do |i|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -347,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
347
347
|
version: '0'
|
348
348
|
requirements: []
|
349
349
|
rubyforge_project:
|
350
|
-
rubygems_version: 2.
|
350
|
+
rubygems_version: 2.4.5
|
351
351
|
signing_key:
|
352
352
|
specification_version: 4
|
353
353
|
summary: Faster implementation of Haml template language.
|