erubi 1.6.1 → 1.7.0
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/CHANGELOG +4 -0
- data/README.rdoc +2 -1
- data/lib/erubi.rb +1 -1
- data/lib/erubi/capture_end.rb +1 -1
- data/test/test.rb +71 -7
- 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: '06927703ddb707650937af01e62308503844ea83'
|
4
|
+
data.tar.gz: a15b6bf8a5bcc28f16aa5ccc4e607946816c6fac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1319c023421b758f72d2a0c07d67fa1e1267879a3eb82999a523154b9b7bdd6fdd23b8767f4f058f72c5e75720670271df5f8e70a10e7d1101748962d0e4e386
|
7
|
+
data.tar.gz: 2a35f88d8c20279919fac6704fe0bc51ed4fcba6d56fb2e6ff7a1fde03c7ea44691a14da10588333daeeb4eb61b3cdae68700006424894fd1dd447eeb0b203ed
|
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -45,7 +45,8 @@ Rails 5.1+.
|
|
45
45
|
|
46
46
|
Erubi does not support capturing block output into the template by default.
|
47
47
|
However, it comes with an +erubi/capture_end+ file that supports capturing
|
48
|
-
via <tt><%|=</tt
|
48
|
+
via <tt><%|=</tt> and <tt><%|==</tt> tags which are closed with a
|
49
|
+
<tt><%|</tt> tag:
|
49
50
|
|
50
51
|
<%|= form do %>
|
51
52
|
<input>
|
data/lib/erubi.rb
CHANGED
data/lib/erubi/capture_end.rb
CHANGED
@@ -28,7 +28,7 @@ module Erubi
|
|
28
28
|
when '|=', '|=='
|
29
29
|
rspace = nil if tailch && !tailch.empty?
|
30
30
|
add_text(lspace) if lspace
|
31
|
-
escape_capture = ((indicator == '|=') ^ @escape_capture)
|
31
|
+
escape_capture = !((indicator == '|=') ^ @escape_capture)
|
32
32
|
src << "begin; (#{@bufstack} ||= []) << #{@bufvar}; #{@bufvar} = #{@bufval}; #{@bufstack}.last << #{@escapefunc if escape_capture}((" << code
|
33
33
|
add_text(rspace) if rspace
|
34
34
|
when '|'
|
data/test/test.rb
CHANGED
@@ -64,6 +64,16 @@ describe Erubi::Engine do
|
|
64
64
|
@a << 'd'
|
65
65
|
@a * 2
|
66
66
|
end
|
67
|
+
def self.quux
|
68
|
+
@a << "a"
|
69
|
+
3.times do |i|
|
70
|
+
@a << "c#{i}"
|
71
|
+
yield i
|
72
|
+
@a << "d#{i}"
|
73
|
+
end
|
74
|
+
@a << "b"
|
75
|
+
@a.upcase
|
76
|
+
end
|
67
77
|
end
|
68
78
|
|
69
79
|
it "should handle no options" do
|
@@ -159,6 +169,22 @@ END3
|
|
159
169
|
@a.must_equal 'bar'
|
160
170
|
end
|
161
171
|
|
172
|
+
it "should have <%|= with CaptureEndEngine not escape by default" do
|
173
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>').src).must_equal '&'
|
174
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape=>false).src).must_equal '&'
|
175
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape_capture=>false).src).must_equal '&'
|
176
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape=>true).src).must_equal '&'
|
177
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape_capture=>true).src).must_equal '&'
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should have <%|== with CaptureEndEngine escape by default" do
|
181
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>').src).must_equal '&'
|
182
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape=>true).src).must_equal '&'
|
183
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape_capture=>true).src).must_equal '&'
|
184
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape=>false).src).must_equal '&'
|
185
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape_capture=>false).src).must_equal '&'
|
186
|
+
end
|
187
|
+
|
162
188
|
[['', false], ['=', true]].each do |ind, escape|
|
163
189
|
it "should allow <%|=#{ind} and <%| for capturing with CaptureEndEngine with :escape_capture => #{escape} and :escape => #{!escape}" do
|
164
190
|
@options[:bufvar] = '@a'
|
@@ -178,7 +204,7 @@ END3
|
|
178
204
|
END1
|
179
205
|
#{'__erubi = ::Erubi;' unless escape}@a = String.new; @a << '<table>
|
180
206
|
<tbody>
|
181
|
-
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last <<
|
207
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do @a << '
|
182
208
|
'; @a << ' <b>'; @a << #{!escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
|
183
209
|
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
184
210
|
'; @a << ' </tbody>
|
@@ -189,7 +215,7 @@ END2
|
|
189
215
|
<table>
|
190
216
|
<tbody>
|
191
217
|
A
|
192
|
-
|
218
|
+
<B>&</B>
|
193
219
|
B
|
194
220
|
</tbody>
|
195
221
|
</table>
|
@@ -214,7 +240,7 @@ END3
|
|
214
240
|
END1
|
215
241
|
#{'__erubi = ::Erubi;' if escape}@a = String.new; @a << '<table>
|
216
242
|
<tbody>
|
217
|
-
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do @a << '
|
243
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
|
218
244
|
'; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
|
219
245
|
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
220
246
|
'; @a << ' </tbody>
|
@@ -225,13 +251,51 @@ END2
|
|
225
251
|
<table>
|
226
252
|
<tbody>
|
227
253
|
A
|
228
|
-
|
254
|
+
<B>&AMP;</B>
|
229
255
|
B
|
230
256
|
</tbody>
|
231
257
|
</table>
|
232
258
|
END3
|
233
259
|
end
|
234
260
|
|
261
|
+
it "should handle loops in <%|=#{ind} and <%| for capturing with CaptureEndEngine when with :escape => #{escape}" do
|
262
|
+
@options[:bufvar] = '@a'
|
263
|
+
@options[:escape] = escape
|
264
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
265
|
+
setup_bar
|
266
|
+
check_output(<<END1, <<END2, <<END3){}
|
267
|
+
<table>
|
268
|
+
<tbody>
|
269
|
+
<%|=#{ind} quux do |i| %>
|
270
|
+
<b><%=#{ind} "\#{i}&" %></b>
|
271
|
+
<%| end %>
|
272
|
+
</tbody>
|
273
|
+
</table>
|
274
|
+
END1
|
275
|
+
#{'__erubi = ::Erubi;' if escape}@a = String.new; @a << '<table>
|
276
|
+
<tbody>
|
277
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( quux do |i| @a << '
|
278
|
+
'; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( "\#{i}&" )); @a << '</b>
|
279
|
+
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
280
|
+
'; @a << ' </tbody>
|
281
|
+
</table>
|
282
|
+
';
|
283
|
+
@a.to_s
|
284
|
+
END2
|
285
|
+
<table>
|
286
|
+
<tbody>
|
287
|
+
AC0
|
288
|
+
<B>0&AMP;</B>
|
289
|
+
D0C1
|
290
|
+
<B>1&AMP;</B>
|
291
|
+
D1C2
|
292
|
+
<B>2&AMP;</B>
|
293
|
+
D2B
|
294
|
+
</tbody>
|
295
|
+
</table>
|
296
|
+
END3
|
297
|
+
end
|
298
|
+
|
235
299
|
it "should allow <%|=#{ind} and <%| for nested capturing with CaptureEndEngine when with :escape => #{escape}" do
|
236
300
|
@options[:bufvar] = '@a'
|
237
301
|
@options[:escape] = escape
|
@@ -249,9 +313,9 @@ END3
|
|
249
313
|
END1
|
250
314
|
#{'__erubi = ::Erubi;' if escape}@a = String.new; @a << '<table>
|
251
315
|
<tbody>
|
252
|
-
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do @a << '
|
316
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
|
253
317
|
'; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
|
254
|
-
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( baz do @a << 'e'; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
318
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( baz do @a << 'e'; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
255
319
|
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
256
320
|
'; @a << ' </tbody>
|
257
321
|
</table>
|
@@ -261,7 +325,7 @@ END2
|
|
261
325
|
<table>
|
262
326
|
<tbody>
|
263
327
|
A
|
264
|
-
|
328
|
+
<B>&AMP;</B>
|
265
329
|
CEDCED
|
266
330
|
B
|
267
331
|
</tbody>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erubi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
70
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.6.
|
71
|
+
rubygems_version: 2.6.13
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: Small ERB Implementation
|