fast_haml 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e396fc6a76d932fc231a39783109c56be41fd5d2
4
- data.tar.gz: 637ffb6b8faa7caf60cf8be200826740da3d521a
3
+ metadata.gz: 82e5ebff407e25bb08be2e8130a90cca37e0bfc6
4
+ data.tar.gz: ac737189d9a874166e57300520d1f58179420e03
5
5
  SHA512:
6
- metadata.gz: 6a9bbe7b0da60b072fb9c5eab60d8292e549e5b78989b6ff5e109de846e0321dd5425f5f92bcb85c534a3153e2889953950384d68d896cad01db5d73d362976c
7
- data.tar.gz: fcb46c42e9801024c85e1232c92222f079c37c60694796b4ec682c4dd72a97499508aef4fc4584348b9dba9f71c6902b01a2b098871e552cc6bd79b7bd224aab
6
+ metadata.gz: a9afecde05c50d903af4ef9fa480fbc89e8bfacc41256311a2a754a4acaa382128551ed2c9d20d57137db7747a66957230abd0ec4cda9e0c02a4aac88d49b941
7
+ data.tar.gz: 2fc94f166bbf3b2830fa123968c995bf73e96ee23b75a2b933ce789f3b5fe056274b9af01db342d7a62fd9e3a1662f5df15b66b723657822c69c248cb26dc68e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.3 (2015-02-27)
2
+ - Fix internal compiler error when `>` is used
3
+ - Fix newline generation at Ast::Element case
4
+
1
5
  ## 0.1.2 (2015-02-24)
2
6
  - Keep newlines for better backtrace (#4)
3
7
 
@@ -87,12 +87,15 @@ module FastHaml
87
87
  if c.is_a?(Ast::Element) && c.nuke_outer_whitespace && was_newline
88
88
  # pop newline
89
89
  x = temple.pop
90
- if x != [:newline]
91
- raise "InternalError: Unexpected pop (expected [:newline]): #{x}"
92
- end
93
- x = temple.pop
94
- if x != [:static, "\n"]
95
- raise "InternalError: Unexpected pop (expected [:static, newline]): #{x}"
90
+ if x == [:newline]
91
+ x = temple.pop
92
+ if x != [:static, "\n"]
93
+ raise "InternalError: Unexpected pop (expected [:static, \\n]): #{x}"
94
+ end
95
+ elsif x == [:static, "\n"]
96
+ # nothing
97
+ else
98
+ raise "InternalError: Unexpected pop (expected [:newline] or [:static, \\n]): #{x}"
96
99
  end
97
100
  unless suppress_code_newline?(c.oneline_child)
98
101
  temple << [:newline]
@@ -125,7 +128,10 @@ module FastHaml
125
128
  end
126
129
 
127
130
  def suppress_code_newline?(ast)
128
- ast.is_a?(Ast::Script) || ast.is_a?(Ast::SilentScript) || (ast.is_a?(Ast::Element) && suppress_code_newline?(ast.oneline_child))
131
+ ast.is_a?(Ast::Script) ||
132
+ ast.is_a?(Ast::SilentScript) ||
133
+ (ast.is_a?(Ast::Element) && suppress_code_newline?(ast.oneline_child)) ||
134
+ (ast.is_a?(Ast::Element) && !ast.children.empty?)
129
135
  end
130
136
 
131
137
  def compile_text(ast)
@@ -185,6 +191,7 @@ module FastHaml
185
191
  unless nuke_inner_whitespace?(ast)
186
192
  children << [:static, "\n"]
187
193
  end
194
+ children << [:newline]
188
195
  compile_children(ast, children)
189
196
  temple << children
190
197
  end
@@ -1,3 +1,3 @@
1
1
  module FastHaml
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ class LineVerifier < StandardError
4
+ def initialize
5
+ super("raised at #{caller_locations(1, 1)[0].lineno}")
6
+ end
7
+ end
8
+
9
+ module LineVerifierHelper
10
+ extend RSpec::Matchers::DSL
11
+
12
+ matcher :raised_at do |expected|
13
+ match do |actual|
14
+ actual == "raised at #{expected}"
15
+ end
16
+ end
17
+ end
18
+
19
+ RSpec.describe 'FastHaml::Compiler newline generation', type: :render do
20
+ include LineVerifierHelper
21
+
22
+ it do
23
+ expect { render_string(<<HAML) }.to raise_error(LineVerifier, raised_at(3))
24
+ %div
25
+ %span= 1
26
+ %span>= raise LineVerifier
27
+ HAML
28
+ end
29
+
30
+ it do
31
+ expect { render_string(<<HAML) }.to raise_error(LineVerifier, raised_at(2))
32
+ %img
33
+ %img{href: raise(LineVerifier)}>
34
+ %img
35
+ HAML
36
+ end
37
+
38
+ it do
39
+ expect { render_string(<<'HAML') }.to raise_error(LineVerifier, raised_at(3))
40
+ %div
41
+ %span hello
42
+ %span #{raise LineVerifier}
43
+ %span world
44
+ HAML
45
+ end
46
+ end
@@ -140,6 +140,11 @@ HAML
140
140
  %img
141
141
  %span> hello
142
142
  %img
143
+ HAML
144
+ expect(render_string(<<HAML)).to eq("<div>\n<span>1</span><span>hoge</span></div>\n")
145
+ %div
146
+ %span= 1
147
+ %span> hoge
143
148
  HAML
144
149
  end
145
150
 
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.2
4
+ version: 0.1.3
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-02-24 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils
@@ -251,6 +251,7 @@ files:
251
251
  - lib/fast_haml/text_compiler.rb
252
252
  - lib/fast_haml/tilt.rb
253
253
  - lib/fast_haml/version.rb
254
+ - spec/compiler_newline_spec.rb
254
255
  - spec/rails/Rakefile
255
256
  - spec/rails/app/assets/images/.keep
256
257
  - spec/rails/app/assets/javascripts/application.js
@@ -351,6 +352,7 @@ signing_key:
351
352
  specification_version: 4
352
353
  summary: Faster implementation of Haml template language.
353
354
  test_files:
355
+ - spec/compiler_newline_spec.rb
354
356
  - spec/rails/Rakefile
355
357
  - spec/rails/app/assets/images/.keep
356
358
  - spec/rails/app/assets/javascripts/application.js