erbse 0.1.2 → 0.1.3

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
- SHA1:
3
- metadata.gz: 77e9086b4307a32040e9853a10a23bef166a0a70
4
- data.tar.gz: 584fb610b0bc9ada7d9a585be6c884b1556ba905
2
+ SHA256:
3
+ metadata.gz: a7fbd1dec8733c0729e2deca42168eb95696704b85c0b0d9c37a1d14e64587ba
4
+ data.tar.gz: 0fbe06409ad39912f9b4e81183426c54a7f05be522ccc16f395640f304611280
5
5
  SHA512:
6
- metadata.gz: 7da9ee8cc19f748691923be30243eaed954fa701be099e95d8c70648c4d94b810cbebde572f32fb5520d125529711342b6efc62afda130d5bbbea7bf0d27194a
7
- data.tar.gz: c40f64e244d4236e4c221ef5748a714d9096c5e8e3953fced3e434ed3c0a55065b025d1f025fd839d8e93e6d49791bc617f287324424db8def34a707dac400b3
6
+ metadata.gz: 512cfadfb79da8590ed0f19cd1f0f69eaf157cbef7004b6e0b6053c14df5cb95cd3980157e2cc98b4d51a60e47452fc838330da997eaa1c7e3308ba65f8aec0e
7
+ data.tar.gz: f8bfa636d35d4cbff380b7c9926a8b2ae520ac6441f61b156379c90dc29904e993d97738b113ab5dde68aa5652723e482935e2c66d9d898c9a98dd4ed8df1bc0
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.3
2
+
3
+ * Do not trim whitespace between ERB tags.
4
+
1
5
  # 0.1.2
2
6
 
3
7
  * Postfix conditionals are now parsed properly: code such as `<% puts if true %>` now works, thanks to @aiomaster's work.
@@ -29,7 +29,7 @@ module Erbse
29
29
  pos = match.end(0)
30
30
  ch = indicator ? indicator[0] : nil
31
31
 
32
- if text and !text.strip.empty? # text
32
+ if text and !text.empty? # text
33
33
  buffers.last << [:static, text]
34
34
  end
35
35
 
@@ -1,3 +1,3 @@
1
1
  module Erbse
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -16,19 +16,22 @@ Text
16
16
 
17
17
  it "what" do
18
18
  Erbse::Parser.new.(str).must_equal [:multi,
19
+ [:static, "\n"],
19
20
  [:dynamic, " true "], [:newline],
20
21
  [:static, "Text\n"],
21
22
  [:erb, :block, " form_for do ", [:multi,
22
23
  [:dynamic, " 1 "],
23
24
  [:code, " 2 "], [:newline],
25
+ [:static, " "],
24
26
  [:erb, :block, " nested do ", [:multi, [:newline],
27
+ [:static, " "],
25
28
  [:dynamic, " this "], [:newline],
26
29
  [:static, " <a/>\n "],
27
30
  ]], [:newline]]]]
28
31
  end
29
32
 
30
33
  it "generates ruby" do
31
- code = %{_buf = []; _buf << ( true ); @; _buf << ("Text@@".freeze); _erbse_blockfilter1 = form_for do ; _erbse_blockfilter2 = ''; _erbse_blockfilter2 << (( 1 ).to_s); 2 ; @; _erbse_blockfilter3 = nested do ; _erbse_blockfilter4 = ''; @; _erbse_blockfilter4 << (( this ).to_s); @; _erbse_blockfilter4 << (" <a/>@@ ".freeze); _erbse_blockfilter4; end; _erbse_blockfilter2 << ((_erbse_blockfilter3).to_s); @; _erbse_blockfilter2; end; _buf << (_erbse_blockfilter1); _buf = _buf.join("".freeze)}
34
+ code = %{_buf = []; _buf << ("@@".freeze); _buf << ( true ); @; _buf << ("Text@@".freeze); _erbse_blockfilter1 = form_for do ; _erbse_blockfilter2 = ''; _erbse_blockfilter2 << (( 1 ).to_s); 2 ; @; _erbse_blockfilter2 << (" ".freeze); _erbse_blockfilter3 = nested do ; _erbse_blockfilter4 = ''; @; _erbse_blockfilter4 << (" ".freeze); _erbse_blockfilter4 << (( this ).to_s); @; _erbse_blockfilter4 << (" <a/>@@ ".freeze); _erbse_blockfilter4; end; _erbse_blockfilter2 << ((_erbse_blockfilter3).to_s); @; _erbse_blockfilter2; end; _buf << (_erbse_blockfilter1); _buf = _buf.join("".freeze)}
32
35
  ruby = Erbse::Engine.new.(str).gsub("\n", "@").gsub('\n', "@@")
33
36
  # puts ruby
34
37
  ruby.must_equal code
@@ -36,39 +39,38 @@ Text
36
39
 
37
40
  describe "<% %>" do
38
41
  let (:str) { %{
39
- <% self %>
40
42
  <% 2.times do |i| %>
41
43
  <%= i+1 %>
42
44
  <% puts %>
43
45
  <% end %>
44
46
 
45
- <% if 1 %>
47
+ <% if 1 == 1 %>
46
48
  Hello
47
49
  <% end %>
48
50
  }
49
51
  }
50
52
  it "what" do
51
53
  Erbse::Parser.new.(str).must_equal [:multi,
52
- [:code, " self "], [:newline],
53
- [:block, " 2.times do |i| ", [:multi, [:newline],
54
- [:dynamic, " i+1 "], [:newline],
54
+ [:static, "\n"],
55
+ [:block, " 2.times do |i| ", [:multi,
56
+ [:newline],
57
+ [:static, " "],
58
+ [:dynamic, " i+1 "], [:newline], [:static, " "],
55
59
  [:code, " puts "], [:newline]]], [:newline],
56
- [:block, " if 1 ", [:multi, [:newline],
57
- [:static, " Hello
58
- "]]], [:newline]]
60
+ [:block, " if 1 == 1 ", [:multi, [:newline],
61
+ [:static, " Hello\n"]]], [:newline]]
59
62
  end
60
63
 
61
64
  it do
62
65
  ruby = Erbse::Engine.new.(str)
63
66
  ruby = ruby.gsub("\n", "@")
64
-
65
67
  # ruby.must_equal %{_buf = []; self ; 2.times do |i| ; _buf << ( i+1 ); puts ; end; _buf = _buf.join(\"\".freeze)}
66
- ruby.must_equal '_buf = []; self ; @; 2.times do |i| ; @; _buf << ( i+1 ); @; puts ; @; end; @; if 1 ; @; _buf << (" Hello\n".freeze); end; @; _buf = _buf.join("".freeze)'
68
+ ruby.must_equal '_buf = []; _buf << ("\n".freeze); 2.times do |i| ; @; _buf << (" ".freeze); _buf << ( i+1 ); @; _buf << (" ".freeze); puts ; @; end; @; if 1 == 1 ; @; _buf << (" Hello\n".freeze); end; @; _buf = _buf.join("".freeze)'
67
69
  end
68
70
 
69
71
  it do
70
72
  ruby = Erbse::Engine.new.(str)
71
- eval(ruby).must_equal "12 Hello\n"
73
+ eval(ruby).must_equal "\n 1 2 Hello\n"
72
74
  end
73
75
  end
74
76
 
@@ -166,6 +168,26 @@ blubb</b>} }
166
168
  it { Erbse::Parser.new.(%{<% form do |i| %>1<% end %>}).must_equal [:multi, [:block, " form do |i| ", [:multi, [:static, "1"]]]] }
167
169
  end
168
170
 
171
+ describe "quoted conditional" do
172
+ let (:str2) { %{
173
+ <%= form_for do %>
174
+ <%= link_to "string", path, "v-if" => "trigger" %>
175
+ <% end %>}
176
+ }
177
+
178
+ it "parses quoted conditionals correctly" do
179
+ Erbse::Parser.new.(str2).must_equal [:multi,
180
+ [:static, "\n "],
181
+ [:erb, :block, " form_for do ", [:multi,
182
+ [:newline],
183
+ [:static, " "],
184
+ [:dynamic, " link_to \"string\", path, \"v-if\" => \"trigger\" "],
185
+ [:newline],
186
+ [:static, " "]
187
+ ]]]
188
+ end
189
+ end
190
+
169
191
  describe "<%@ %>" do
170
192
  let (:str) { %{<%@ content = capture do %>
171
193
  Yo!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erbse
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
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-25 00:00:00.000000000 Z
11
+ date: 2018-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.6.8
101
+ rubygems_version: 2.7.3
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Updated Erubis.