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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4dbc3b15e30a6c37e0c932d0dc6e2407cc3102e
4
- data.tar.gz: 0e6c9d24076c83e7b5f76fdf88112db10f4bf854
3
+ metadata.gz: 82c2cd008b3cb7f86bf02d80ad69ae0655bd88b6
4
+ data.tar.gz: a06febaeb2ccf36598a2d612f8dd9de3e367f8c3
5
5
  SHA512:
6
- metadata.gz: af1d8ee121870759f5215c9efa0de024c6e48d74e46b15ba142793df427f8eb8cb53fd8182633b6d59262628e8916382fc00eec8b818ae82b1a28687d8f5b6a5
7
- data.tar.gz: 482e94239ea3a5f2b5c124f7fe1ae3c89a7bbcd412c70a12db1a2ecbf44a9e58886f9cfbc7e5f63fc215de4a0b3bb944b1043a49e6e3a8612ea5ac03363362a0
6
+ metadata.gz: 26b7a473dd89a20eb8dcef16c14b435157ea054ae8aac72bd19782959bc8de54d010c119580f6c5bd6a1617f19e1d0b20354e2d5691a2f2428df173a52bfb0c5
7
+ data.tar.gz: 15431eb000c43add9ab90cfd19167c52a5c23f0cee9fdc56b84bbcdbd7d40b1fbbdfd12bf5ddd89df5e102f861d6621550a28d4e8d98e8a404c02d9f10d858b7
@@ -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
 
@@ -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
- code = FastHaml::Engine.new.call(File.read(template))
18
- obj.instance_eval("def fast_haml; #{code}; end")
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 rendering') do
22
+ x.report('Haml') do
21
23
  obj.haml
22
24
  end
23
25
 
24
- x.report('FastHaml rendering') do
25
- obj.fast_haml
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!
@@ -318,10 +318,15 @@ module FastHaml
318
318
 
319
319
  def compile_script(ast)
320
320
  sym = unique_name
321
- temple = [:multi, [:code, "#{sym} = #{ast.script}"], [:newline]]
322
- compile_children(ast, temple)
323
- if !ast.children.empty? && !ast.mid_block_keyword
324
- temple << [:code, 'end']
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]
@@ -92,7 +92,7 @@ module FastHaml
92
92
  s.pos = 1
93
93
  depth = 1
94
94
  loop do
95
- depth = ParserUtils.balance(s, '{', '}')
95
+ depth = ParserUtils.balance(s, '{', '}', depth)
96
96
  if depth == 0
97
97
  attr = s.pre_match + s.matched
98
98
  return [attr[1, attr.size-2], s.rest.lstrip]
@@ -1,3 +1,3 @@
1
1
  module FastHaml
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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
 
@@ -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.5
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-01 00:00:00.000000000 Z
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.2.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.