inversion 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/ChangeLog +157 -28
- data/History.rdoc +8 -0
- data/Manifest.txt +2 -3
- data/Rakefile +1 -3
- data/lib/inversion.rb +2 -2
- data/lib/inversion/exceptions.rb +1 -1
- data/lib/inversion/{template/parser.rb → parser.rb} +5 -5
- data/lib/inversion/renderstate.rb +55 -5
- data/lib/inversion/template.rb +5 -3
- data/lib/inversion/template/attrtag.rb +19 -12
- data/lib/inversion/template/begintag.rb +1 -2
- data/lib/inversion/template/configtag.rb +7 -1
- data/lib/inversion/template/containertag.rb +8 -3
- data/lib/inversion/template/elsetag.rb +16 -0
- data/lib/inversion/template/elsiftag.rb +16 -0
- data/lib/inversion/template/escapetag.rb +1 -1
- data/lib/inversion/template/fortag.rb +2 -5
- data/lib/inversion/template/iftag.rb +17 -35
- data/lib/inversion/template/importtag.rb +2 -1
- data/lib/inversion/template/includetag.rb +2 -0
- data/lib/inversion/template/node.rb +1 -1
- data/lib/inversion/template/tag.rb +5 -2
- data/lib/inversion/template/textnode.rb +1 -2
- data/lib/inversion/template/unlesstag.rb +16 -26
- data/lib/inversion/template/yieldtag.rb +3 -8
- data/spec/inversion/{template/parser_spec.rb → parser_spec.rb} +14 -14
- data/spec/inversion/renderstate_spec.rb +242 -165
- data/spec/inversion/template/attrtag_spec.rb +10 -18
- data/spec/inversion/template/begintag_spec.rb +13 -12
- data/spec/inversion/template/configtag_spec.rb +5 -7
- data/spec/inversion/template/elsetag_spec.rb +5 -5
- data/spec/inversion/template/elsiftag_spec.rb +5 -5
- data/spec/inversion/template/endtag_spec.rb +1 -1
- data/spec/inversion/template/fortag_spec.rb +22 -1
- data/spec/inversion/template/iftag_spec.rb +14 -0
- data/spec/inversion/template/rescuetag_spec.rb +4 -4
- data/spec/inversion/template/tag_spec.rb +6 -4
- data/spec/inversion/template/unlesstag_spec.rb +12 -6
- data/spec/inversion/template/yieldtag_spec.rb +2 -2
- metadata +31 -32
- metadata.gz.sig +0 -0
- data/lib/inversion/template/conditionaltag.rb +0 -49
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,8 +1,137 @@
|
|
1
|
+
2011-09-27 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* .hgtags:
|
4
|
+
Added tag v0.2.0 for changeset 9b57bc8611b2
|
5
|
+
[8f0b8b864b1a] [tip]
|
6
|
+
|
7
|
+
* .hgsigs:
|
8
|
+
Added signature for changeset 896d23953a0a
|
9
|
+
[9b57bc8611b2] [v0.2.0]
|
10
|
+
|
11
|
+
* History.rdoc, lib/inversion.rb:
|
12
|
+
Bumped minor version, updated History for release.
|
13
|
+
[896d23953a0a]
|
14
|
+
|
15
|
+
* lib/inversion/renderstate.rb, lib/inversion/template/begintag.rb,
|
16
|
+
lib/inversion/template/elsetag.rb,
|
17
|
+
lib/inversion/template/elsiftag.rb,
|
18
|
+
lib/inversion/template/escapetag.rb,
|
19
|
+
lib/inversion/template/fortag.rb, lib/inversion/template/iftag.rb,
|
20
|
+
lib/inversion/template/importtag.rb,
|
21
|
+
lib/inversion/template/includetag.rb,
|
22
|
+
lib/inversion/template/textnode.rb,
|
23
|
+
lib/inversion/template/unlesstag.rb,
|
24
|
+
lib/inversion/template/yieldtag.rb,
|
25
|
+
spec/inversion/renderstate_spec.rb,
|
26
|
+
spec/inversion/template/begintag_spec.rb,
|
27
|
+
spec/inversion/template/yieldtag_spec.rb:
|
28
|
+
Refactoring, renaming 'RenderState#tag_state' to '#tag_data'.
|
29
|
+
- Made tags that inherit from containertag super to its #render where
|
30
|
+
possible.
|
31
|
+
- Move YieldTag's render state into RenderState#tag_data
|
32
|
+
- Comment fixes, spec naming consistency fixes
|
33
|
+
[5ec9728367d2]
|
34
|
+
|
35
|
+
* lib/inversion/exceptions.rb, lib/inversion/parser.rb,
|
36
|
+
lib/inversion/template.rb, lib/inversion/template/node.rb,
|
37
|
+
lib/inversion/template/parser.rb, spec/inversion/parser_spec.rb,
|
38
|
+
spec/inversion/template/elsetag_spec.rb,
|
39
|
+
spec/inversion/template/elsiftag_spec.rb,
|
40
|
+
spec/inversion/template/endtag_spec.rb,
|
41
|
+
spec/inversion/template/parser_spec.rb,
|
42
|
+
spec/inversion/template/rescuetag_spec.rb:
|
43
|
+
Rename Inversion::Template::Parser to Inversion::Parser.
|
44
|
+
[d0daee0bf3c6]
|
45
|
+
|
46
|
+
2011-09-26 Michael Granger <ged@FaerieMUD.org>
|
47
|
+
|
48
|
+
* Manifest.txt, lib/inversion/renderstate.rb,
|
49
|
+
lib/inversion/template.rb, lib/inversion/template/attrtag.rb,
|
50
|
+
lib/inversion/template/begintag.rb,
|
51
|
+
lib/inversion/template/conditionaltag.rb,
|
52
|
+
lib/inversion/template/containertag.rb,
|
53
|
+
lib/inversion/template/elsetag.rb,
|
54
|
+
lib/inversion/template/elsiftag.rb,
|
55
|
+
lib/inversion/template/fortag.rb, lib/inversion/template/iftag.rb,
|
56
|
+
lib/inversion/template/tag.rb, lib/inversion/template/unlesstag.rb,
|
57
|
+
spec/inversion/renderstate_spec.rb,
|
58
|
+
spec/inversion/template/attrtag_spec.rb,
|
59
|
+
spec/inversion/template/elsiftag_spec.rb,
|
60
|
+
spec/inversion/template/fortag_spec.rb,
|
61
|
+
spec/inversion/template/iftag_spec.rb,
|
62
|
+
spec/inversion/template/unlesstag_spec.rb:
|
63
|
+
Fixed conditional rendering inside of 'for' tags (fixes #2):
|
64
|
+
- Make the 'for' tag use the append operator of the RenderState
|
65
|
+
instead of accumulating rendered output itself
|
66
|
+
- Added a tag state to the RenderState that tags can use to keep per-
|
67
|
+
render state and pass messages to other tags.
|
68
|
+
- Added a render toggle for conditional render output
|
69
|
+
- Removed the ConditionalTag mixin, which is no longer necessary
|
70
|
+
- Move else/elsif tag logic into the tags themselves
|
71
|
+
[8a4bfb043423]
|
72
|
+
|
73
|
+
* spec/inversion/renderstate_spec.rb:
|
74
|
+
Organized renderstate specs by feature
|
75
|
+
[beb6e6ea06f4]
|
76
|
+
|
77
|
+
* lib/inversion/template/tag.rb, spec/inversion/template/tag_spec.rb:
|
78
|
+
Added a partial fix for the plugin loader so it won't load old
|
79
|
+
plugins. It's only partial because it will load renamed or removed
|
80
|
+
tags from older versions, but it won't ever result in clobbering or
|
81
|
+
redefining legitimate tags. (fixes #1)
|
82
|
+
[0eebd4b78d1a]
|
83
|
+
|
84
|
+
2011-09-24 Michael Granger <ged@FaerieMUD.org>
|
85
|
+
|
86
|
+
* experiments/if-in-for-mintest.rb:
|
87
|
+
Added a minimial test case for the if+for issue (refs #2)
|
88
|
+
[3e8a6b3cae2b]
|
89
|
+
|
90
|
+
* lib/inversion/template/configtag.rb,
|
91
|
+
spec/inversion/template/configtag_spec.rb:
|
92
|
+
Bugfix: Make the config tag set options while rendering, too.
|
93
|
+
[9636249a559e]
|
94
|
+
|
1
95
|
2011-09-23 Michael Granger <ged@FaerieMUD.org>
|
2
96
|
|
97
|
+
* .hgtags:
|
98
|
+
Added tag v0.1.1 for changeset 3aed7786335c
|
99
|
+
[936ad3e2b5b7]
|
100
|
+
|
101
|
+
* .hgsigs:
|
102
|
+
Added signature for changeset d700486aff8c
|
103
|
+
[3aed7786335c] [v0.1.1]
|
104
|
+
|
105
|
+
* History.rdoc, lib/inversion.rb:
|
106
|
+
Bump patch version for release.
|
107
|
+
[d700486aff8c]
|
108
|
+
|
109
|
+
* lib/inversion/renderstate.rb,
|
110
|
+
lib/inversion/template/subscribetag.rb,
|
111
|
+
spec/inversion/template/subscribetag_spec.rb:
|
112
|
+
Work around a bug in the 'subscribe' tag that caused templates to
|
113
|
+
accumulate published nodes.
|
114
|
+
[e745f77580bb]
|
115
|
+
|
116
|
+
* README.rdoc:
|
117
|
+
Move the tag list from the README to the wiki
|
118
|
+
[ddf55e389f5e]
|
119
|
+
|
120
|
+
* .hgtags:
|
121
|
+
Added tag v0.1.0 for changeset a1eb55ebf68a
|
122
|
+
[3c6b8c616671]
|
123
|
+
|
124
|
+
* .hgsigs:
|
125
|
+
Added signature for changeset 5bb3f4fad426
|
126
|
+
[a1eb55ebf68a] [v0.1.0]
|
127
|
+
|
128
|
+
* History.rdoc:
|
129
|
+
Updated the history file.
|
130
|
+
[5bb3f4fad426]
|
131
|
+
|
3
132
|
* lib/inversion.rb:
|
4
133
|
Bump minor version for new release.
|
5
|
-
[dbc96c7b052a]
|
134
|
+
[dbc96c7b052a]
|
6
135
|
|
7
136
|
* lib/inversion/template.rb, lib/inversion/template/tag.rb,
|
8
137
|
lib/inversion/template/timedeltatag.rb,
|
@@ -20,7 +149,7 @@
|
|
20
149
|
|
21
150
|
* manual/resources/css/manual.css, manual/resources/css/reset.css:
|
22
151
|
Fixing CSS font-face declarations; adding missing reset.css
|
23
|
-
[45f04400b244]
|
152
|
+
[45f04400b244] [github/master]
|
24
153
|
|
25
154
|
* .hgtags:
|
26
155
|
Added tag v0.0.4 for changeset 7a412b7ed72b
|
@@ -62,10 +191,6 @@
|
|
62
191
|
Avoid Pathname#expand_path in Inversion::Template.load [profiled]
|
63
192
|
[91cbb0c90b85]
|
64
193
|
|
65
|
-
* Rakefile:
|
66
|
-
Disable the .gemtest task that hoe defines without asking
|
67
|
-
[cf76def7d9cf]
|
68
|
-
|
69
194
|
2011-09-16 Michael Granger <ged@FaerieMUD.org>
|
70
195
|
|
71
196
|
* lib/inversion/template/elsiftag.rb:
|
@@ -76,6 +201,12 @@
|
|
76
201
|
Fix shadowed variable in BeginTag#handle_exception.
|
77
202
|
[8424ac44da4a]
|
78
203
|
|
204
|
+
2011-09-21 Michael Granger <ged@FaerieMUD.org>
|
205
|
+
|
206
|
+
* Rakefile:
|
207
|
+
Disable the .gemtest task that hoe defines without asking
|
208
|
+
[cf76def7d9cf]
|
209
|
+
|
79
210
|
2011-08-17 Michael Granger <ged@FaerieMUD.org>
|
80
211
|
|
81
212
|
* manual/resources/css/manual.css:
|
@@ -129,7 +260,7 @@
|
|
129
260
|
manual/src/gettingstarted.page, manual/src/index.page,
|
130
261
|
manual/src/tags.page, manual/src/templates.page:
|
131
262
|
Adding a manual
|
132
|
-
[e0193bdb57db]
|
263
|
+
[e0193bdb57db]
|
133
264
|
|
134
265
|
2011-08-15 Michael Granger <ged@FaerieMUD.org>
|
135
266
|
|
@@ -472,16 +603,6 @@
|
|
472
603
|
* Merged with b822cc9b6ff2
|
473
604
|
[f46b1ff133cd]
|
474
605
|
|
475
|
-
2011-07-05 Mahlon E. Smith <mahlon@martini.nu>
|
476
|
-
|
477
|
-
* lib/inversion/template/pptag.rb, spec/inversion/mixins_spec.rb,
|
478
|
-
spec/inversion/template/pptag_spec.rb:
|
479
|
-
Heh, added the pp tag and mixin spec files back from changeset
|
480
|
-
5d244064e631. Whoops.
|
481
|
-
[b822cc9b6ff2]
|
482
|
-
|
483
|
-
2011-07-06 Michael Granger <ged@FaerieMUD.org>
|
484
|
-
|
485
606
|
* .hgignore, README.md, Rakefile, lib/inversion.rb,
|
486
607
|
lib/inversion/monkeypatches.rb, lib/inversion/renderstate.rb,
|
487
608
|
lib/inversion/template.rb, lib/inversion/template/attrtag.rb,
|
@@ -538,6 +659,14 @@
|
|
538
659
|
- Add SimpleCov coverage ()
|
539
660
|
[4d7a94c4cf02]
|
540
661
|
|
662
|
+
2011-07-05 Mahlon E. Smith <mahlon@martini.nu>
|
663
|
+
|
664
|
+
* lib/inversion/template/pptag.rb, spec/inversion/mixins_spec.rb,
|
665
|
+
spec/inversion/template/pptag_spec.rb:
|
666
|
+
Heh, added the pp tag and mixin spec files back from changeset
|
667
|
+
5d244064e631. Whoops.
|
668
|
+
[b822cc9b6ff2]
|
669
|
+
|
541
670
|
2011-07-05 Michael Granger <ged@FaerieMUD.org>
|
542
671
|
|
543
672
|
* Rakefile, lib/inversion/sinatra.rb, lib/inversion/tilt.rb,
|
@@ -925,14 +1054,6 @@
|
|
925
1054
|
Merged with dc16cc877dfc, updated README
|
926
1055
|
[0fdf3122bf7c]
|
927
1056
|
|
928
|
-
* README.md, experiments/erb_scope_bleed.rb:
|
929
|
-
Fleshing out the README, adding scope-bleedover example
|
930
|
-
[f44b597af8bd]
|
931
|
-
|
932
|
-
* lib/inversion.rb:
|
933
|
-
Removing checked-in revision value
|
934
|
-
[773feca505b8]
|
935
|
-
|
936
1057
|
2011-04-06 Michael Granger <ged@FaerieMUD.org>
|
937
1058
|
|
938
1059
|
* .irbrc, Rakefile, experiments/ripper_spike.rb, lib/inversion.rb,
|
@@ -961,6 +1082,10 @@
|
|
961
1082
|
* Merging with b50fef00621b
|
962
1083
|
[861b21a30656]
|
963
1084
|
|
1085
|
+
* lib/inversion.rb:
|
1086
|
+
Clearing Revision tag
|
1087
|
+
[cdacb5f98f93]
|
1088
|
+
|
964
1089
|
2011-02-07 Mahlon E. Smith <mahlon@martini.nu>
|
965
1090
|
|
966
1091
|
* lib/inversion/template.rb, lib/inversion/template/attr_tag.rb,
|
@@ -971,11 +1096,15 @@
|
|
971
1096
|
Checkpoint, fleshing out Tags.
|
972
1097
|
[4a4fc3f1dc14]
|
973
1098
|
|
974
|
-
2011-
|
1099
|
+
2011-04-12 Michael Granger <ged@FaerieMUD.org>
|
1100
|
+
|
1101
|
+
* README.md, experiments/erb_scope_bleed.rb:
|
1102
|
+
Fleshing out the README, adding scope-bleedover example
|
1103
|
+
[f44b597af8bd]
|
975
1104
|
|
976
1105
|
* lib/inversion.rb:
|
977
|
-
|
978
|
-
[
|
1106
|
+
Removing checked-in revision value
|
1107
|
+
[773feca505b8]
|
979
1108
|
|
980
1109
|
2011-02-07 Mahlon E. Smith <mahlon@martini.nu>
|
981
1110
|
|
data/History.rdoc
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== v0.2.0 [2011-09-27] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- Bugfixes (#1, #2)
|
4
|
+
- Renamed Inversion::Template::Parser to Inversion::Parser
|
5
|
+
- Added RenderState#tag_state for tracking tag state on a
|
6
|
+
per-render basis.
|
7
|
+
|
8
|
+
|
1
9
|
== v0.1.1 [2011-09-23] Michael Granger <ged@FaerieMUD.org>
|
2
10
|
|
3
11
|
- Bugfix for the Subscribe tag.
|
data/Manifest.txt
CHANGED
@@ -8,6 +8,7 @@ lib/inversion.rb
|
|
8
8
|
lib/inversion/exceptions.rb
|
9
9
|
lib/inversion/mixins.rb
|
10
10
|
lib/inversion/monkeypatches.rb
|
11
|
+
lib/inversion/parser.rb
|
11
12
|
lib/inversion/renderstate.rb
|
12
13
|
lib/inversion/sinatra.rb
|
13
14
|
lib/inversion/template.rb
|
@@ -16,7 +17,6 @@ lib/inversion/template/begintag.rb
|
|
16
17
|
lib/inversion/template/calltag.rb
|
17
18
|
lib/inversion/template/codetag.rb
|
18
19
|
lib/inversion/template/commenttag.rb
|
19
|
-
lib/inversion/template/conditionaltag.rb
|
20
20
|
lib/inversion/template/configtag.rb
|
21
21
|
lib/inversion/template/containertag.rb
|
22
22
|
lib/inversion/template/defaulttag.rb
|
@@ -29,7 +29,6 @@ lib/inversion/template/iftag.rb
|
|
29
29
|
lib/inversion/template/importtag.rb
|
30
30
|
lib/inversion/template/includetag.rb
|
31
31
|
lib/inversion/template/node.rb
|
32
|
-
lib/inversion/template/parser.rb
|
33
32
|
lib/inversion/template/pptag.rb
|
34
33
|
lib/inversion/template/publishtag.rb
|
35
34
|
lib/inversion/template/rescuetag.rb
|
@@ -45,6 +44,7 @@ lib/inversion/utils.rb
|
|
45
44
|
spec/data/sinatra/hello.inversion
|
46
45
|
spec/inversion/mixins_spec.rb
|
47
46
|
spec/inversion/monkeypatches_spec.rb
|
47
|
+
spec/inversion/parser_spec.rb
|
48
48
|
spec/inversion/renderstate_spec.rb
|
49
49
|
spec/inversion/sinatra_spec.rb
|
50
50
|
spec/inversion/template/attrtag_spec.rb
|
@@ -64,7 +64,6 @@ spec/inversion/template/iftag_spec.rb
|
|
64
64
|
spec/inversion/template/importtag_spec.rb
|
65
65
|
spec/inversion/template/includetag_spec.rb
|
66
66
|
spec/inversion/template/node_spec.rb
|
67
|
-
spec/inversion/template/parser_spec.rb
|
68
67
|
spec/inversion/template/pptag_spec.rb
|
69
68
|
spec/inversion/template/publishtag_spec.rb
|
70
69
|
spec/inversion/template/rescuetag_spec.rb
|
data/Rakefile
CHANGED
@@ -36,6 +36,7 @@ hoespec = Hoe.spec 'inversion' do
|
|
36
36
|
self.spec_extras[:licenses] = ["BSD"]
|
37
37
|
self.require_ruby_version( '>=1.9.2' )
|
38
38
|
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
39
|
+
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
39
40
|
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
40
41
|
end
|
41
42
|
|
@@ -44,9 +45,6 @@ ENV['VERSION'] ||= hoespec.spec.version.to_s
|
|
44
45
|
# Ensure the specs pass before checking in
|
45
46
|
task 'hg:precheckin' => :spec
|
46
47
|
|
47
|
-
# Rebuild the ChangeLog immediately before release (hoe hook)
|
48
|
-
task :prerelease => 'ChangeLog'
|
49
|
-
|
50
48
|
if Rake::Task.task_defined?( '.gemtest' )
|
51
49
|
Rake::Task['.gemtest'].clear
|
52
50
|
task '.gemtest' do
|
data/lib/inversion.rb
CHANGED
@@ -26,10 +26,10 @@ module Inversion
|
|
26
26
|
require 'inversion/monkeypatches'
|
27
27
|
|
28
28
|
# Library version constant
|
29
|
-
VERSION = '0.
|
29
|
+
VERSION = '0.2.0'
|
30
30
|
|
31
31
|
# Version-control revision constant
|
32
|
-
REVISION = %q$Revision:
|
32
|
+
REVISION = %q$Revision: 896d23953a0a $
|
33
33
|
|
34
34
|
#
|
35
35
|
# Logging
|
data/lib/inversion/exceptions.rb
CHANGED
@@ -7,7 +7,7 @@ module Inversion
|
|
7
7
|
# A generic Inversion exception class
|
8
8
|
class Error < ::RuntimeError; end
|
9
9
|
|
10
|
-
# An exception class raised from the Inversion::
|
10
|
+
# An exception class raised from the Inversion::Parser when
|
11
11
|
# a problem is encountered while parsing a template.
|
12
12
|
class ParseError < Inversion::Error; end
|
13
13
|
|
@@ -10,7 +10,7 @@ require 'inversion/template/endtag'
|
|
10
10
|
|
11
11
|
# This is the parser for Inversion templates. It takes template source and
|
12
12
|
# returns a tree of Inversion::Template::Node objects (if parsing is successful).
|
13
|
-
class Inversion::
|
13
|
+
class Inversion::Parser
|
14
14
|
include Inversion::Loggable
|
15
15
|
|
16
16
|
# The pattern for matching a tag opening
|
@@ -39,7 +39,7 @@ class Inversion::Template::Parser
|
|
39
39
|
}
|
40
40
|
|
41
41
|
|
42
|
-
### Create a new Inversion::
|
42
|
+
### Create a new Inversion::Parser with the specified config +options+.
|
43
43
|
def initialize( template, options={} )
|
44
44
|
@template = template
|
45
45
|
@options = DEFAULT_OPTIONS.merge( options )
|
@@ -63,7 +63,7 @@ class Inversion::Template::Parser
|
|
63
63
|
inherited_state.template = @template
|
64
64
|
state = inherited_state
|
65
65
|
else
|
66
|
-
state = Inversion::
|
66
|
+
state = Inversion::Parser::State.new( @template, self.options )
|
67
67
|
end
|
68
68
|
|
69
69
|
self.log.debug "Starting parse of template source (%0.2fK, %s)" %
|
@@ -290,8 +290,8 @@ class Inversion::Template::Parser
|
|
290
290
|
return Inversion::Template.load( path, substate, self.options )
|
291
291
|
end
|
292
292
|
|
293
|
-
end # class Inversion::
|
293
|
+
end # class Inversion::Parser::State
|
294
294
|
|
295
|
-
end # class Inversion::
|
295
|
+
end # class Inversion::Parser
|
296
296
|
|
297
297
|
|
@@ -31,10 +31,13 @@ class Inversion::RenderState
|
|
31
31
|
@block = block
|
32
32
|
@default_errhandler = self.method( :default_error_handler )
|
33
33
|
@errhandler = @default_errhandler
|
34
|
+
@rendering_enabled = true
|
34
35
|
|
35
|
-
# The rendered output Array,
|
36
|
+
# The rendered output Array, the stack of render destinations and
|
37
|
+
# tag states
|
36
38
|
@output = []
|
37
39
|
@destinations = [ @output ]
|
40
|
+
@tag_data = [ {} ]
|
38
41
|
|
39
42
|
# Hash of subscribed Nodes, keyed by the subscription key as a Symbol
|
40
43
|
@subscriptions = Hash.new {|hsh, k| hsh[k] = [] } # Auto-vivify
|
@@ -75,6 +78,12 @@ class Inversion::RenderState
|
|
75
78
|
end
|
76
79
|
|
77
80
|
|
81
|
+
### Return a Hash that tags can use to track state for the current render.
|
82
|
+
def tag_data
|
83
|
+
return @tag_data.last
|
84
|
+
end
|
85
|
+
|
86
|
+
|
78
87
|
### Evaluate the specified +code+ in the context of itself and
|
79
88
|
### return the result.
|
80
89
|
def eval( code )
|
@@ -98,6 +107,21 @@ class Inversion::RenderState
|
|
98
107
|
end
|
99
108
|
|
100
109
|
|
110
|
+
### Add an overlay to the current tag state Hash, yield to the provided block, then
|
111
|
+
### revert the tag state back to what it was prior to running the block.
|
112
|
+
def with_tag_data( newhash={} )
|
113
|
+
raise LocalJumpError, "no block given" unless block_given?
|
114
|
+
self.log.debug "Overriding tag state with: %p" % [ newhash ]
|
115
|
+
|
116
|
+
begin
|
117
|
+
@tag_data.push( @tag_data.last.merge(newhash) )
|
118
|
+
yield( self )
|
119
|
+
ensure
|
120
|
+
@tag_data.pop
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
101
125
|
### Override the state's render destination, call the block, then restore the original
|
102
126
|
### destination when the block returns.
|
103
127
|
def with_destination( new_destination )
|
@@ -174,10 +198,12 @@ class Inversion::RenderState
|
|
174
198
|
node = node.render( self )
|
175
199
|
end
|
176
200
|
|
177
|
-
self.
|
178
|
-
|
179
|
-
|
180
|
-
|
201
|
+
if self.rendering_enabled?
|
202
|
+
self.log.debug " adding a %p to the destination (%p)" %
|
203
|
+
[ node.class, self.destination.class ]
|
204
|
+
self.destination << node
|
205
|
+
self.log.debug " just appended %p to %p" % [ node, self.destination ]
|
206
|
+
end
|
181
207
|
rescue ::StandardError => err
|
182
208
|
self.log.debug " handling a %p while rendering: %s" % [ err.class, err.message ]
|
183
209
|
self.destination << self.handle_render_error( original_node, err )
|
@@ -265,6 +291,30 @@ class Inversion::RenderState
|
|
265
291
|
end
|
266
292
|
|
267
293
|
|
294
|
+
### Return +true+ if rendered nodes are being saved for output.
|
295
|
+
def rendering_enabled?
|
296
|
+
return @rendering_enabled ? true : false
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
### Enable rendering, causing nodes to be appended to the rendered output.
|
301
|
+
def enable_rendering
|
302
|
+
@rendering_enabled = true
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
### Disable rendering, causing rendered nodes to be discarded instead of appended.
|
307
|
+
def disable_rendering
|
308
|
+
@rendering_enabled = false
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
### Toggle rendering, enabling it if it was disabled, and vice-versa.
|
313
|
+
def toggle_rendering
|
314
|
+
@rendering_enabled = !@rendering_enabled
|
315
|
+
end
|
316
|
+
|
317
|
+
|
268
318
|
### Return a human-readable representation of the object.
|
269
319
|
def inspect
|
270
320
|
return "#<%p:0x%08x containerstate: %s, attributes: %s, destination: %p>" % [
|