rendry 0.2.0 → 0.2.1
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/lib/rendry/version.rb +1 -1
- data/lib/rendry.rb +15 -26
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 043bde156ddb2a1af19b6c8507e676330b4ad40a079cc8850ced810396559dfa
|
|
4
|
+
data.tar.gz: bf349c54a7025081672066beb879e8ca8fa4d5e2eecf81c80c4f23f2cec85d50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8912d9c980908d713576dc50307c2ef7b9bd09a9f0be7a3072ea8507b6d491c6af0236f84a428f9adc384702195fdfb6a966322a9f5422f709462699a9ad910b
|
|
7
|
+
data.tar.gz: 1dd76f09af3eccbf79b653abcbc0c1371b27a4f281699a35157264244e637799ac1124d50dfb8343fde8866225a2401d13de16dae7c39502ddb5a87780067e6d
|
data/lib/rendry/version.rb
CHANGED
data/lib/rendry.rb
CHANGED
|
@@ -69,15 +69,8 @@ module Rendry
|
|
|
69
69
|
if block
|
|
70
70
|
children = Builder.new(enabled: @enabled)
|
|
71
71
|
result = Rendry.evaluate(children, &block)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
output = output.dup if output.frozen?
|
|
75
|
-
output << CGI.escapeHTML(result.to_s)
|
|
76
|
-
elsif result.is_a?(SafeHTML)
|
|
77
|
-
output = output.dup if output.frozen?
|
|
78
|
-
output << result
|
|
79
|
-
end
|
|
80
|
-
content = SafeHTML.new(output)
|
|
72
|
+
children.append_result(result)
|
|
73
|
+
content = SafeHTML.new(children.render)
|
|
81
74
|
end
|
|
82
75
|
|
|
83
76
|
output = +"<#{name}#{format_attributes(attributes)}>"
|
|
@@ -153,15 +146,13 @@ module Rendry
|
|
|
153
146
|
helper = context && context.respond_to?(name) ? context.method(name) : nil
|
|
154
147
|
has_arguments = !(content.nil? && attributes.empty? && !block)
|
|
155
148
|
if helper && !(helper.arity == 0 && has_arguments)
|
|
156
|
-
|
|
149
|
+
if content.nil? && attributes.empty? && !block
|
|
157
150
|
context.public_send(name)
|
|
158
151
|
elsif content.nil?
|
|
159
152
|
context.public_send(name, **attributes, &block)
|
|
160
153
|
else
|
|
161
154
|
context.public_send(name, content, **attributes, &block)
|
|
162
155
|
end
|
|
163
|
-
write_escaped_result(result)
|
|
164
|
-
self
|
|
165
156
|
else
|
|
166
157
|
tag(name.to_s.tr("_", "-"), content, **attributes, &block)
|
|
167
158
|
end
|
|
@@ -174,18 +165,19 @@ module Rendry
|
|
|
174
165
|
name.to_s.match?(/\A[a-z][a-z0-9_]*\z/) || super
|
|
175
166
|
end
|
|
176
167
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def write(string)
|
|
180
|
-
@output << string if @enabled
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def write_escaped_result(result)
|
|
168
|
+
def append_result(result)
|
|
184
169
|
if result.is_a?(SafeHTML)
|
|
185
170
|
write result
|
|
186
171
|
elsif Rendry.appendable_result?(result)
|
|
187
172
|
write CGI.escapeHTML(result.to_s)
|
|
188
173
|
end
|
|
174
|
+
self
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
private
|
|
178
|
+
|
|
179
|
+
def write(string)
|
|
180
|
+
@output << string if @enabled
|
|
189
181
|
end
|
|
190
182
|
|
|
191
183
|
def refresh_wrapper(html, config)
|
|
@@ -255,11 +247,7 @@ module Rendry
|
|
|
255
247
|
|
|
256
248
|
builder = Builder.new
|
|
257
249
|
result = Rendry.evaluate(builder, self, context: view_context, &block)
|
|
258
|
-
|
|
259
|
-
builder.output << result
|
|
260
|
-
elsif Rendry.appendable_result?(result)
|
|
261
|
-
builder.output << CGI.escapeHTML(result.to_s)
|
|
262
|
-
end
|
|
250
|
+
builder.append_result(result)
|
|
263
251
|
SafeHTML.new(builder.render)
|
|
264
252
|
end
|
|
265
253
|
end
|
|
@@ -467,14 +455,15 @@ module Rendry
|
|
|
467
455
|
Thread.current[:rendry_current_fragments] = fragments.map(&:to_s)
|
|
468
456
|
Thread.current[:rendry_root_builder] = builder
|
|
469
457
|
begin
|
|
470
|
-
evaluate(builder, &block)
|
|
458
|
+
result = evaluate(builder, &block)
|
|
471
459
|
ensure
|
|
472
460
|
Thread.current[:rendry_current_fragments] = previous_fragments
|
|
473
461
|
Thread.current[:rendry_root_builder] = previous_root
|
|
474
462
|
end
|
|
475
463
|
else
|
|
476
|
-
evaluate(builder, &block)
|
|
464
|
+
result = evaluate(builder, &block)
|
|
477
465
|
end
|
|
466
|
+
builder.append_result(result)
|
|
478
467
|
SafeHTML.new(builder.render)
|
|
479
468
|
end
|
|
480
469
|
|