inversion 0.17.2 → 0.17.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +7 -0
- data/Tags.rdoc +110 -135
- data/lib/inversion.rb +2 -2
- data/lib/inversion/renderstate.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce3df399edaec700d90c634d354a1f452df4fbbd
|
4
|
+
data.tar.gz: 3df0b15958d115c2a4013ccfa6fbc1bf39b5a7bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc101d2dddd1c7e70fdf8ad014edaa81db0ea79661f0475636a9906b566066225044d974febc034ef12a6fa0a78510d0c71e5013fb89ee4613230d49a6345ede
|
7
|
+
data.tar.gz: 4be23c2a5f052059043748da5837ed6936c18b4b3fcde7533cac74994208d72cfc509edcf532ee8d5f37f6a4ed1f7fe8bfab5a3f720940c7733eafddca1e073f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== v0.17.3 [2015-02-16] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- Performance fix: Re-comment the #inspect logging message
|
4
|
+
in the RenderState
|
5
|
+
- Updated tag docs
|
6
|
+
|
7
|
+
|
1
8
|
== v0.17.2 [2015-01-22] Michael Granger <ged@FaerieMUD.org>
|
2
9
|
|
3
10
|
- Fix a bug with the fragment tag.
|
data/Tags.rdoc
CHANGED
@@ -18,139 +18,6 @@ The second form is especially useful if you're generating HTML and want to put a
|
|
18
18
|
You can mix tag forms in a single document.
|
19
19
|
|
20
20
|
|
21
|
-
== Tags
|
22
|
-
|
23
|
-
=== begin/rescue
|
24
|
-
|
25
|
-
These tags work as you'd expect from their ruby counterparts.
|
26
|
-
|
27
|
-
The +begin+ section of the template to be rendered only if no exceptions are raised while it's
|
28
|
-
being rendered. If an exception is raised, it is checked against any +rescue+ sections, and the
|
29
|
-
first with a matching exception is rendered instead. If no +rescue+ block is found, the exception
|
30
|
-
is handled by the configured exception behavior for the template (see Inversion::Template@Template+Options).
|
31
|
-
|
32
|
-
<?begin ?><?call employees.length ?><?end?>
|
33
|
-
|
34
|
-
<?begin ?>
|
35
|
-
<?for employee in employees.all ?>
|
36
|
-
<?attr employee.name ?> --> <?attr employee.title ?>
|
37
|
-
<?end for?>
|
38
|
-
<?rescue DatabaseError => err ?>
|
39
|
-
Oh no!! I can't talk to the database for some reason. The
|
40
|
-
error was as follows:
|
41
|
-
<pre>
|
42
|
-
<?attr err.message ?>
|
43
|
-
</pre>
|
44
|
-
<?end?>
|
45
|
-
|
46
|
-
=== comment
|
47
|
-
|
48
|
-
The +comment+ tag can be used to temporarily stop a section of a document from being rendered:
|
49
|
-
|
50
|
-
<?comment?>
|
51
|
-
This stuff won't be rendered.
|
52
|
-
<?end comment ?>
|
53
|
-
But this stuff will.
|
54
|
-
|
55
|
-
Note that the tags inside the comment will still be parsed, so the template's interface won't be affected by the comment:
|
56
|
-
|
57
|
-
<?comment?>
|
58
|
-
<?attr content ?>
|
59
|
-
<?end comment ?>
|
60
|
-
|
61
|
-
If you have +debugging_comments+ enabled in the template options[rdoc-ref:Templates@Template+Options], sections which are commented out will be rendered as a comment describing what was omitted, surrounded by the comment characters set in +comment_start+ and +comment_end+ options, respectively.
|
62
|
-
|
63
|
-
<!-- Commented out 1 nodes on line 1 -->
|
64
|
-
|
65
|
-
You can also embed a description of why the section is commented in the tag body, which will be used as a label when rendering the comment. For example:
|
66
|
-
|
67
|
-
<?comment Disabled until there's content ?>
|
68
|
-
<?attr content ?>
|
69
|
-
<?end comment ?>
|
70
|
-
|
71
|
-
will be rendered as:
|
72
|
-
|
73
|
-
<!-- Commented out 1 nodes on line 1: Disabled until there's content -->
|
74
|
-
|
75
|
-
|
76
|
-
=== config
|
77
|
-
|
78
|
-
The +config+ tag can be used to override template options[Templates@Template+Options]
|
79
|
-
on a per-template basis. It allows for convenient, inline settings from
|
80
|
-
within a template rather than from the code in which the template is
|
81
|
-
loaded.
|
82
|
-
|
83
|
-
For example, if you want to enable debugging comments on a single template:
|
84
|
-
|
85
|
-
<?config debugging_comments: true ?>
|
86
|
-
|
87
|
-
Multiple template options can be set simultaneously by using a YAML hash:
|
88
|
-
|
89
|
-
<?config
|
90
|
-
on_render_error: propagate
|
91
|
-
debugging_comments: true
|
92
|
-
comment_start: /*
|
93
|
-
comment_end: */
|
94
|
-
?>
|
95
|
-
|
96
|
-
Note that this also allows you to set multiple options on a single line, if you wrap them in braces:
|
97
|
-
|
98
|
-
<?config { comment_start: "/*", comment_end: "*/" } ?>
|
99
|
-
|
100
|
-
|
101
|
-
=== default
|
102
|
-
|
103
|
-
The +default+ tag sets an attribute from within the template, and this value is used if the attribute is otherwise unset.
|
104
|
-
|
105
|
-
template = Inversion::Template.new <<-TMPL
|
106
|
-
<?default adjective to "cruel" ?>
|
107
|
-
<?default noun to "world" ?>
|
108
|
-
Goodbye, <?attr adjective ?> <?attr noun ?>!
|
109
|
-
TMPL
|
110
|
-
|
111
|
-
template.render
|
112
|
-
|
113
|
-
template.adjective = "delicious"
|
114
|
-
template.render
|
115
|
-
|
116
|
-
template.adjective = nil
|
117
|
-
template.noun = "banana"
|
118
|
-
template.render
|
119
|
-
|
120
|
-
Would produce the output:
|
121
|
-
|
122
|
-
Goodbye, cruel world!
|
123
|
-
Goodbye, delicious world!
|
124
|
-
Goodbye, cruel banana!
|
125
|
-
|
126
|
-
|
127
|
-
=== fragment
|
128
|
-
|
129
|
-
A +fragment+ tag also sets an attribute from within the template, but under the scope of the global
|
130
|
-
template itself. A fragment can use other Inversion tags, and the attribute is both usable
|
131
|
-
elsewhere in the template, and accessible from calling code after rendering.
|
132
|
-
|
133
|
-
template = Inversion::Template.new <<-TMPL
|
134
|
-
<?fragment subject ?>Your order status (Order #<?call order.number ?>)<?end ?>
|
135
|
-
|
136
|
-
Dear <?call order.customer.name ?>,
|
137
|
-
|
138
|
-
Your recent order was modified by our Order Fulfillment Team.
|
139
|
-
|
140
|
-
After careful deliberation, it was decided that no one should have need for that many hot dogs
|
141
|
-
with overnight shipping. Frankly, we're more than a little concerned for your health.
|
142
|
-
|
143
|
-
Sincerely,
|
144
|
-
Rowe's Meat Emporium
|
145
|
-
(Buy! Sell! Consignment!)
|
146
|
-
TMPL
|
147
|
-
|
148
|
-
template.order = order
|
149
|
-
template.render
|
150
|
-
|
151
|
-
template.fragments[ :subject ] #=> "Your order status (Order #3492)"
|
152
|
-
|
153
|
-
|
154
21
|
== Placeholder Tags
|
155
22
|
|
156
23
|
Placeholder tags represent the main functionality of Inversion; they create a placeholder in the output text which can be filled in via a method on the template object with the same name.
|
@@ -231,9 +98,9 @@ Dates are compared against the current time, and render to approximate descripti
|
|
231
98
|
* less than a minute from now
|
232
99
|
|
233
100
|
|
234
|
-
==
|
101
|
+
== Inter-template Tags
|
235
102
|
|
236
|
-
|
103
|
+
These tags operate on nested templates, allowing you to selectively use or send attributes or content from other templates.
|
237
104
|
|
238
105
|
|
239
106
|
=== import
|
@@ -401,6 +268,34 @@ The +include+ tag allows inclusion of other template files from within a templat
|
|
401
268
|
Your Friends at Spime Thorpe!
|
402
269
|
|
403
270
|
|
271
|
+
=== fragment
|
272
|
+
|
273
|
+
A +fragment+ tag also sets an attribute from within the template, but under the
|
274
|
+
scope of the global template itself. A fragment can use other Inversion tags,
|
275
|
+
and the attribute is both usable elsewhere in the template, and accessible from
|
276
|
+
calling code after rendering.
|
277
|
+
|
278
|
+
template = Inversion::Template.new <<-TMPL
|
279
|
+
<?fragment subject ?>Your order status (Order #<?call order.number ?>)<?end ?>
|
280
|
+
|
281
|
+
Dear <?call order.customer.name ?>,
|
282
|
+
|
283
|
+
Your recent order was modified by our Order Fulfillment Team.
|
284
|
+
|
285
|
+
After careful deliberation, it was decided that no one should have need for that many hot dogs
|
286
|
+
with overnight shipping. Frankly, we're more than a little concerned for your health.
|
287
|
+
|
288
|
+
Sincerely,
|
289
|
+
Rowe's Meat Emporium
|
290
|
+
(Buy! Sell! Consignment!)
|
291
|
+
TMPL
|
292
|
+
|
293
|
+
template.order = order
|
294
|
+
template.render
|
295
|
+
|
296
|
+
template.fragments[ :subject ] #=> "Your order status (Order #3492)"
|
297
|
+
|
298
|
+
|
404
299
|
== Flow Control
|
405
300
|
|
406
301
|
The following tags are used to alter the flow of rendering from within templates.
|
@@ -517,6 +412,86 @@ The +yield+ tag is used to defer rendering of some part of the template to the c
|
|
517
412
|
This will insert the +report_table+ template in place of the yield, but only if $DEBUG is true.
|
518
413
|
|
519
414
|
|
415
|
+
=== begin/rescue
|
416
|
+
|
417
|
+
These tags work as you'd expect from their ruby counterparts.
|
418
|
+
|
419
|
+
The +begin+ section of the template to be rendered only if no exceptions are raised while it's
|
420
|
+
being rendered. If an exception is raised, it is checked against any +rescue+ sections, and the
|
421
|
+
first with a matching exception is rendered instead. If no +rescue+ block is found, the exception
|
422
|
+
is handled by the configured exception behavior for the template (see Inversion::Template@Template+Options).
|
423
|
+
|
424
|
+
<?begin ?><?call employees.length ?><?end?>
|
425
|
+
|
426
|
+
<?begin ?>
|
427
|
+
<?for employee in employees.all ?>
|
428
|
+
<?attr employee.name ?> --> <?attr employee.title ?>
|
429
|
+
<?end for?>
|
430
|
+
<?rescue DatabaseError => err ?>
|
431
|
+
Oh no!! I can't talk to the database for some reason. The
|
432
|
+
error was as follows:
|
433
|
+
<pre>
|
434
|
+
<?attr err.message ?>
|
435
|
+
</pre>
|
436
|
+
<?end?>
|
437
|
+
|
438
|
+
|
439
|
+
== Control Tags
|
440
|
+
|
441
|
+
There are a few tags that can be used to set values in the templating system itself.
|
442
|
+
|
443
|
+
=== config
|
444
|
+
|
445
|
+
The +config+ tag can be used to override template options[Templates@Template+Options]
|
446
|
+
on a per-template basis. It allows for convenient, inline settings from
|
447
|
+
within a template rather than from the code in which the template is
|
448
|
+
loaded.
|
449
|
+
|
450
|
+
For example, if you want to enable debugging comments on a single template:
|
451
|
+
|
452
|
+
<?config debugging_comments: true ?>
|
453
|
+
|
454
|
+
Multiple template options can be set simultaneously by using a YAML hash:
|
455
|
+
|
456
|
+
<?config
|
457
|
+
on_render_error: propagate
|
458
|
+
debugging_comments: true
|
459
|
+
comment_start: /*
|
460
|
+
comment_end: */
|
461
|
+
?>
|
462
|
+
|
463
|
+
Note that this also allows you to set multiple options on a single line, if you wrap them in braces:
|
464
|
+
|
465
|
+
<?config { comment_start: "/*", comment_end: "*/" } ?>
|
466
|
+
|
467
|
+
|
468
|
+
=== default
|
469
|
+
|
470
|
+
The +default+ tag sets an attribute from within the template, and this value is used if the attribute is otherwise unset.
|
471
|
+
|
472
|
+
template = Inversion::Template.new <<-TMPL
|
473
|
+
<?default adjective to "cruel" ?>
|
474
|
+
<?default noun to "world" ?>
|
475
|
+
Goodbye, <?attr adjective ?> <?attr noun ?>!
|
476
|
+
TMPL
|
477
|
+
|
478
|
+
template.render
|
479
|
+
|
480
|
+
template.adjective = "delicious"
|
481
|
+
template.render
|
482
|
+
|
483
|
+
template.adjective = nil
|
484
|
+
template.noun = "banana"
|
485
|
+
template.render
|
486
|
+
|
487
|
+
Would produce the output:
|
488
|
+
|
489
|
+
Goodbye, cruel world!
|
490
|
+
Goodbye, delicious world!
|
491
|
+
Goodbye, cruel banana!
|
492
|
+
|
493
|
+
|
494
|
+
|
520
495
|
== Troubleshooting/Introspection
|
521
496
|
|
522
497
|
=== pp
|
data/lib/inversion.rb
CHANGED
@@ -26,10 +26,10 @@ module Inversion
|
|
26
26
|
warn ">>> Inversion requires Ruby 2.0.0 or later. <<<" if RUBY_VERSION < '2.0.0'
|
27
27
|
|
28
28
|
# Library version constant
|
29
|
-
VERSION = '0.17.
|
29
|
+
VERSION = '0.17.3'
|
30
30
|
|
31
31
|
# Version-control revision constant
|
32
|
-
REVISION = %q$Revision:
|
32
|
+
REVISION = %q$Revision: ad70311aa386 $
|
33
33
|
|
34
34
|
|
35
35
|
### Get the Inversion version.
|
@@ -479,7 +479,7 @@ class Inversion::RenderState
|
|
479
479
|
|
480
480
|
### Return the given +nodes+ as a String in the configured encoding.
|
481
481
|
def stringify_nodes( nodes )
|
482
|
-
self.log.debug "Rendering nodes: %p" % [ nodes ]
|
482
|
+
# self.log.debug "Rendering nodes: %p" % [ nodes ]
|
483
483
|
strings = nodes.flatten.map( &:to_s )
|
484
484
|
|
485
485
|
if enc = self.options[ :encoding ]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
|
32
32
|
ggcrPfcYeTwWlfZPu2LrBg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-
|
34
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: loggability
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
t�T4=�ɵd�I�_@�����]���$w��Y �~�+ �:X���x���ǯ0u���{r�K�!���
|
2
|
+
:�;ș��{�X�S���;͔��S|� ҙ�n
|
3
|
+
w5�6>TI0���`���bQc���O�!�����s[|٣&L�m��h���LQ3���gL�� �9p��44�Z������ЃH��� �*���8�*E �����|���q+Hą�4_"�sD��l��7�\�Z���F;�
|