volt 0.8.14 → 0.8.15
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/.gitignore +1 -1
- data/Readme.md +8 -2
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +1 -1
- data/app/volt/models/user.rb +2 -2
- data/app/volt/tasks/live_query/live_query_pool.rb +1 -1
- data/app/volt/tasks/query_tasks.rb +1 -1
- data/app/volt/tasks/store_tasks.rb +1 -1
- data/app/volt/tasks/user_tasks.rb +2 -2
- data/lib/volt/boot.rb +2 -2
- data/lib/volt/cli/asset_compile.rb +31 -27
- data/lib/volt/cli.rb +64 -65
- data/lib/volt/config.rb +25 -23
- data/lib/volt/console.rb +17 -16
- data/lib/volt/controllers/model_controller.rb +82 -80
- data/lib/volt/data_stores/data_store.rb +2 -2
- data/lib/volt/data_stores/mongo_driver.rb +2 -2
- data/lib/volt/extra_core/inflections.rb +2 -2
- data/lib/volt/extra_core/inflector/inflections.rb +185 -183
- data/lib/volt/extra_core/inflector/methods.rb +50 -48
- data/lib/volt/extra_core/string.rb +2 -2
- data/lib/volt/models/array_model.rb +93 -92
- data/lib/volt/models/cursor.rb +3 -2
- data/lib/volt/models/model.rb +248 -251
- data/lib/volt/models/model_hash_behaviour.rb +44 -44
- data/lib/volt/models/model_helpers.rb +38 -36
- data/lib/volt/models/model_state.rb +16 -17
- data/lib/volt/models/model_wrapper.rb +25 -24
- data/lib/volt/models/persistors/array_store.rb +145 -143
- data/lib/volt/models/persistors/base.rb +18 -16
- data/lib/volt/models/persistors/flash.rb +24 -22
- data/lib/volt/models/persistors/local_store.rb +46 -44
- data/lib/volt/models/persistors/model_identity_map.rb +10 -8
- data/lib/volt/models/persistors/model_store.rb +76 -76
- data/lib/volt/models/persistors/params.rb +19 -17
- data/lib/volt/models/persistors/query/query_listener.rb +65 -63
- data/lib/volt/models/persistors/query/query_listener_pool.rb +12 -10
- data/lib/volt/models/persistors/store.rb +28 -28
- data/lib/volt/models/persistors/store_factory.rb +12 -10
- data/lib/volt/models/persistors/store_state.rb +33 -31
- data/lib/volt/models/url.rb +96 -104
- data/lib/volt/models/validations.rb +56 -54
- data/lib/volt/models/validators/length_validator.rb +24 -22
- data/lib/volt/models/validators/presence_validator.rb +14 -12
- data/lib/volt/page/bindings/attribute_binding.rb +106 -106
- data/lib/volt/page/bindings/base_binding.rb +23 -21
- data/lib/volt/page/bindings/component_binding.rb +3 -1
- data/lib/volt/page/bindings/content_binding.rb +34 -34
- data/lib/volt/page/bindings/each_binding.rb +113 -113
- data/lib/volt/page/bindings/event_binding.rb +38 -34
- data/lib/volt/page/bindings/if_binding.rb +56 -54
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +24 -22
- data/lib/volt/page/bindings/template_binding.rb +182 -185
- data/lib/volt/page/channel.rb +79 -77
- data/lib/volt/page/channel_stub.rb +29 -27
- data/lib/volt/page/document.rb +6 -5
- data/lib/volt/page/document_events.rb +54 -52
- data/lib/volt/page/page.rb +139 -138
- data/lib/volt/page/string_template_renderer.rb +36 -36
- data/lib/volt/page/sub_context.rb +26 -25
- data/lib/volt/page/targets/attribute_section.rb +27 -25
- data/lib/volt/page/targets/attribute_target.rb +7 -6
- data/lib/volt/page/targets/base_section.rb +27 -26
- data/lib/volt/page/targets/binding_document/base_node.rb +3 -1
- data/lib/volt/page/targets/binding_document/component_node.rb +85 -82
- data/lib/volt/page/targets/binding_document/html_node.rb +11 -9
- data/lib/volt/page/targets/dom_section.rb +78 -77
- data/lib/volt/page/targets/dom_target.rb +8 -6
- data/lib/volt/page/targets/dom_template.rb +90 -88
- data/lib/volt/page/targets/helpers/comment_searchers.rb +51 -49
- data/lib/volt/page/tasks.rb +59 -57
- data/lib/volt/page/template_renderer.rb +17 -14
- data/lib/volt/page/url_tracker.rb +26 -24
- data/lib/volt/reactive/computation.rb +87 -88
- data/lib/volt/reactive/dependency.rb +30 -28
- data/lib/volt/reactive/eventable.rb +64 -62
- data/lib/volt/reactive/hash_dependency.rb +25 -23
- data/lib/volt/reactive/reactive_accessors.rb +34 -32
- data/lib/volt/reactive/reactive_array.rb +162 -162
- data/lib/volt/reactive/reactive_hash.rb +37 -35
- data/lib/volt/router/routes.rb +99 -101
- data/lib/volt/server/component_handler.rb +20 -21
- data/lib/volt/server/component_templates.rb +72 -70
- data/lib/volt/server/html_parser/attribute_scope.rb +109 -99
- data/lib/volt/server/html_parser/each_scope.rb +17 -16
- data/lib/volt/server/html_parser/if_view_scope.rb +51 -49
- data/lib/volt/server/html_parser/sandlebars_parser.rb +184 -177
- data/lib/volt/server/html_parser/textarea_scope.rb +24 -22
- data/lib/volt/server/html_parser/view_handler.rb +66 -65
- data/lib/volt/server/html_parser/view_parser.rb +23 -21
- data/lib/volt/server/html_parser/view_scope.rb +142 -141
- data/lib/volt/server/rack/asset_files.rb +81 -79
- data/lib/volt/server/rack/component_code.rb +17 -15
- data/lib/volt/server/rack/component_html_renderer.rb +14 -12
- data/lib/volt/server/rack/component_paths.rb +72 -71
- data/lib/volt/server/rack/index_files.rb +36 -39
- data/lib/volt/server/rack/opal_files.rb +43 -41
- data/lib/volt/server/rack/source_map_server.rb +23 -21
- data/lib/volt/server/socket_connection_handler.rb +46 -45
- data/lib/volt/server/socket_connection_handler_stub.rb +21 -19
- data/lib/volt/server.rb +60 -58
- data/lib/volt/spec/setup.rb +3 -3
- data/lib/volt/tasks/dispatcher.rb +24 -23
- data/lib/volt/tasks/task_handler.rb +35 -33
- data/lib/volt/utils/ejson.rb +8 -6
- data/lib/volt/utils/generic_counting_pool.rb +33 -31
- data/lib/volt/utils/generic_pool.rb +73 -70
- data/lib/volt/utils/local_storage.rb +42 -38
- data/lib/volt/volt/environment.rb +1 -1
- data/lib/volt.rb +44 -42
- data/spec/apps/kitchen_sink/app/main/assets/css/todos.css +28 -0
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +1 -0
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +2 -2
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +17 -0
- data/spec/apps/kitchen_sink/app/main/views/main/main.html +1 -0
- data/spec/apps/kitchen_sink/app/main/views/todos/index.html +24 -0
- data/spec/apps/kitchen_sink/config.ru +1 -1
- data/spec/controllers/reactive_accessors_spec.rb +5 -5
- data/spec/extra_core/inflector_spec.rb +2 -2
- data/spec/integration/list_spec.rb +68 -0
- data/spec/models/model_spec.rb +57 -57
- data/spec/models/persistors/params_spec.rb +6 -6
- data/spec/models/persistors/store_spec.rb +7 -7
- data/spec/models/validations_spec.rb +3 -3
- data/spec/page/bindings/content_binding_spec.rb +7 -7
- data/spec/page/bindings/template_binding_spec.rb +4 -5
- data/spec/page/sub_context_spec.rb +2 -2
- data/spec/reactive/computation_spec.rb +10 -10
- data/spec/reactive/dependency_spec.rb +2 -2
- data/spec/reactive/eventable_spec.rb +4 -4
- data/spec/reactive/reactive_array_spec.rb +13 -13
- data/spec/router/routes_spec.rb +5 -5
- data/spec/server/html_parser/sandlebars_parser_spec.rb +9 -9
- data/spec/server/html_parser/view_parser_spec.rb +27 -27
- data/spec/server/rack/asset_files_spec.rb +5 -5
- data/spec/server/rack/component_paths_spec.rb +2 -2
- data/spec/tasks/live_query_spec.rb +2 -2
- data/spec/tasks/query_tasks.rb +1 -1
- data/spec/tasks/query_tracker_spec.rb +1 -1
- data/spec/templates/targets/binding_document/component_node_spec.rb +2 -2
- data/spec/utils/generic_counting_pool_spec.rb +2 -2
- data/spec/utils/generic_pool_spec.rb +2 -2
- data/templates/component/controllers/main_controller.rb +1 -1
- data/templates/model/model.rb.tt +2 -2
- data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +2 -2
- data/templates/project/app/main/controllers/main_controller.rb +1 -1
- data/templates/project/config.ru +1 -1
- metadata +10 -3
- data/app/volt/assets/js/vertxbus.js +0 -216
|
@@ -1,136 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
module Volt
|
|
2
|
+
# Included into ViewScope to provide processing for attributes
|
|
3
|
+
module AttributeScope
|
|
4
|
+
# Take the attributes and create any bindings
|
|
5
|
+
def process_attributes(tag_name, attributes)
|
|
6
|
+
new_attributes = attributes.dup
|
|
7
|
+
|
|
8
|
+
attributes.each_pair do |name, value|
|
|
9
|
+
if name[0..1] == 'e-'
|
|
10
|
+
process_event_binding(tag_name, new_attributes, name, value)
|
|
11
|
+
else
|
|
12
|
+
process_attribute(tag_name, new_attributes, name, value)
|
|
13
|
+
end
|
|
12
14
|
end
|
|
15
|
+
|
|
16
|
+
return new_attributes
|
|
13
17
|
end
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
def process_event_binding(tag_name, attributes, name, value)
|
|
20
|
+
id = add_id_to_attributes(attributes)
|
|
21
|
+
|
|
22
|
+
event = name[2..-1]
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
if tag_name == 'a'
|
|
25
|
+
# For links, we need to add blank href to make it clickable.
|
|
26
|
+
attributes['href'] ||= ''
|
|
27
|
+
end
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
# Remove the e- attribute
|
|
30
|
+
attributes.delete(name)
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
# For links, we need to add blank href to make it clickable.
|
|
25
|
-
attributes['href'] ||= ''
|
|
32
|
+
save_binding(id, "lambda { |__p, __t, __c, __id| Volt::EventBinding.new(__p, __t, __c, __id, #{event.inspect}, Proc.new {|event| #{value} })}")
|
|
26
33
|
end
|
|
27
34
|
|
|
28
|
-
#
|
|
29
|
-
|
|
35
|
+
# Takes a string and splits on bindings, returns the string split on bindings
|
|
36
|
+
# and the number of bindings.
|
|
37
|
+
def binding_parts_and_count(value)
|
|
38
|
+
parts = value.split(/(\{\{[^\}]+\}\})/).reject(&:blank?)
|
|
39
|
+
binding_count = parts.count { |p| p[0] == '{' && p[1] == '{' && p[-2] == '}' && p[-1] == '}' }
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
return parts, binding_count
|
|
42
|
+
end
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
binding_count = parts.count {|p| p[0] == '{' && p[1] == '{' && p[-2] == '}' && p[-1] == '}'}
|
|
44
|
+
def process_attribute(tag_name, attributes, attribute_name, value)
|
|
45
|
+
parts, binding_count = binding_parts_and_count(value)
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
# if this attribute has bindings
|
|
48
|
+
if binding_count > 0
|
|
49
|
+
# Setup an id
|
|
50
|
+
id = add_id_to_attributes(attributes)
|
|
42
51
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
if parts.size > 1
|
|
53
|
+
# Multiple bindings
|
|
54
|
+
add_multiple_attribute(tag_name, id, attribute_name, parts, value)
|
|
55
|
+
elsif parts.size == 1 && binding_count == 1
|
|
56
|
+
# A single binding
|
|
57
|
+
add_single_attribute(id, attribute_name, parts)
|
|
58
|
+
end
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
# Remove the attribute
|
|
61
|
+
attributes.delete(attribute_name)
|
|
62
|
+
end
|
|
53
63
|
end
|
|
54
|
-
end
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
# TODO: We should use a real parser for this
|
|
66
|
+
def getter_to_setter(getter)
|
|
67
|
+
getter = getter.strip
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
# Convert a getter into a setter
|
|
70
|
+
if getter.index('.') || getter.index('@')
|
|
71
|
+
prefix = ''
|
|
72
|
+
else
|
|
73
|
+
prefix = 'self.'
|
|
74
|
+
end
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
return "#{prefix}#{getter}=(val)"
|
|
77
|
+
end
|
|
69
78
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
# Add an attribute binding on the tag, bind directly to the getter in the binding
|
|
80
|
+
def add_single_attribute(id, attribute_name, parts)
|
|
81
|
+
getter = parts[0][2...-2].strip
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
# if getter.index('@')
|
|
84
|
+
# raise "Bindings currently do not support instance variables"
|
|
85
|
+
# end
|
|
77
86
|
|
|
78
|
-
|
|
87
|
+
setter = getter_to_setter(getter)
|
|
79
88
|
|
|
80
|
-
|
|
81
|
-
|
|
89
|
+
save_binding(id, "lambda { |__p, __t, __c, __id| Volt::AttributeBinding.new(__p, __t, __c, __id, #{attribute_name.inspect}, Proc.new { #{getter} }, Proc.new { |val| #{setter} }) }")
|
|
90
|
+
end
|
|
82
91
|
|
|
83
92
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
def add_multiple_attribute(tag_name, id, attribute_name, parts, content)
|
|
94
|
+
case attribute_name
|
|
95
|
+
when 'checked', 'value'
|
|
96
|
+
if parts.size > 1
|
|
97
|
+
if tag_name == 'textarea'
|
|
98
|
+
raise "The content of text area's can not be bound to multiple bindings."
|
|
99
|
+
else
|
|
100
|
+
# Multiple values can not be passed to value or checked attributes.
|
|
101
|
+
raise "Multiple bindings can not be passed to a #{attribute_name} binding: #{parts.inspect}"
|
|
102
|
+
end
|
|
103
|
+
end
|
|
94
104
|
end
|
|
95
|
-
end
|
|
96
105
|
|
|
97
|
-
|
|
106
|
+
string_template_renderer_path = add_string_template_renderer(content)
|
|
98
107
|
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
save_binding(id, "lambda { |__p, __t, __c, __id| Volt::AttributeBinding.new(__p, __t, __c, __id, #{attribute_name.inspect}, Proc.new { Volt::StringTemplateRender.new(__p, __c, #{string_template_renderer_path.inspect}) }) }")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def add_string_template_renderer(content)
|
|
112
|
+
path = @path + "/_rv#{@binding_number}"
|
|
113
|
+
new_handler = ViewHandler.new(path, false)
|
|
114
|
+
@binding_number += 1
|
|
101
115
|
|
|
102
|
-
|
|
103
|
-
path = @path + "/_rv#{@binding_number}"
|
|
104
|
-
new_handler = ViewHandler.new(path, false)
|
|
105
|
-
@binding_number += 1
|
|
116
|
+
SandlebarsParser.new(content, new_handler)
|
|
106
117
|
|
|
107
|
-
|
|
118
|
+
# Close out the last scope
|
|
119
|
+
new_handler.scope.last.close_scope
|
|
108
120
|
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
# Copy in the templates from the new handler
|
|
122
|
+
new_handler.templates.each_pair do |key, value|
|
|
123
|
+
@handler.templates[key] = value
|
|
124
|
+
end
|
|
111
125
|
|
|
112
|
-
|
|
113
|
-
new_handler.templates.each_pair do |key, value|
|
|
114
|
-
@handler.templates[key] = value
|
|
126
|
+
return path
|
|
115
127
|
end
|
|
116
128
|
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
def add_id_to_attributes(attributes)
|
|
130
|
+
id = attributes['id'] ||= "id#{@binding_number}"
|
|
131
|
+
@binding_number += 1
|
|
119
132
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
@binding_number += 1
|
|
133
|
+
return id.to_s
|
|
134
|
+
end
|
|
123
135
|
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
def attribute_string(attributes)
|
|
137
|
+
attr_str = attributes.map { |v| "#{v[0]}=\"#{v[1]}\"" }.join(' ')
|
|
138
|
+
if attr_str.size > 0
|
|
139
|
+
# extra space
|
|
140
|
+
attr_str = " " + attr_str
|
|
141
|
+
end
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
attr_str = attributes.map {|v| "#{v[0]}=\"#{v[1]}\"" }.join(' ')
|
|
129
|
-
if attr_str.size > 0
|
|
130
|
-
# extra space
|
|
131
|
-
attr_str = " " + attr_str
|
|
143
|
+
return attr_str
|
|
132
144
|
end
|
|
133
|
-
|
|
134
|
-
return attr_str
|
|
135
145
|
end
|
|
136
|
-
end
|
|
146
|
+
end
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
module Volt
|
|
2
|
+
class EachScope < ViewScope
|
|
3
|
+
def initialize(handler, path, content)
|
|
4
|
+
super(handler, path)
|
|
5
|
+
# @content, @variable_name = content.strip.split(/ as /)
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
@content, @variable_name = content.split(/.each\s+do\s+\|/)
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def close_scope
|
|
12
|
-
binding_number = @handler.scope[-2].binding_number
|
|
13
|
-
@handler.scope[-2].binding_number += 1
|
|
14
|
-
@path += "/__template/#{binding_number}"
|
|
9
|
+
@variable_name = @variable_name.gsub(/\|/, '')
|
|
10
|
+
end
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
def close_scope
|
|
13
|
+
binding_number = @handler.scope[-2].binding_number
|
|
14
|
+
@handler.scope[-2].binding_number += 1
|
|
15
|
+
@path += "/__template/#{binding_number}"
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
@handler.scope.last.save_binding(binding_number, "lambda { |__p, __t, __c, __id| EachBinding.new(__p, __t, __c, __id, Proc.new { #{@content} }, #{@variable_name.inspect}, #{@path.inspect}) }")
|
|
17
|
+
super
|
|
20
18
|
|
|
19
|
+
@handler.html << "<!-- $#{binding_number} --><!-- $/#{binding_number} -->"
|
|
20
|
+
@handler.scope.last.save_binding(binding_number, "lambda { |__p, __t, __c, __id| Volt::EachBinding.new(__p, __t, __c, __id, Proc.new { #{@content} }, #{@variable_name.inspect}, #{@path.inspect}) }")
|
|
21
|
+
end
|
|
21
22
|
end
|
|
22
|
-
end
|
|
23
|
+
end
|
|
@@ -1,71 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
module Volt
|
|
2
|
+
class IfViewScope < ViewScope
|
|
3
|
+
def initialize(handler, path, content)
|
|
4
|
+
super(handler, path)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
@original_path = @path
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
@last_content = content
|
|
9
|
+
@branches = []
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
# We haven't added the if yet
|
|
12
|
+
@if_binding_number = @handler.last.binding_number
|
|
13
|
+
@handler.last.binding_number += 1
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
@path_number = 0
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
new_path
|
|
18
|
+
end
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
def new_path
|
|
21
|
+
@path = @original_path + "/__if#{@path_number}"
|
|
22
|
+
@path_number += 1
|
|
23
|
+
end
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
# When we reach an else block, we basically commit the current html
|
|
26
|
+
# and template, and start a new one.
|
|
27
|
+
def add_else(content)
|
|
28
|
+
close_scope(false)
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
@last_content = content
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
# Clear existing
|
|
33
|
+
@html = ''
|
|
34
|
+
@bindings = {}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
# Close scope removes us, so lets add it back.
|
|
37
|
+
@handler.scope << self
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
@binding_number = 0
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
# Generate a new template path for this section.
|
|
42
|
+
new_path
|
|
43
|
+
end
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
def close_scope(final=true)
|
|
46
|
+
@branches << [@last_content, path]
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
super()
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
if final
|
|
51
|
+
# Add the binding to the parent
|
|
52
|
+
branches = @branches.map do |branch|
|
|
53
|
+
content = branch[0]
|
|
54
|
+
if content == nil
|
|
55
|
+
content = nil.inspect
|
|
56
|
+
else
|
|
57
|
+
content = "Proc.new { #{branch[0]} }"
|
|
58
|
+
end
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
"[#{content}, #{branch[1].inspect}]"
|
|
61
|
+
end.join(', ')
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
new_scope = @handler.last
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
# variables are captured for branches, so we must prefix them so they don't conflict.
|
|
66
|
+
# page, target, context, id
|
|
67
|
+
new_scope.save_binding(@if_binding_number, "lambda { |__p, __t, __c, __id| Volt::IfBinding.new(__p, __t, __c, __id, [#{branches}]) }")
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
new_scope.html << "<!-- $#{@if_binding_number} --><!-- $/#{@if_binding_number} -->"
|
|
70
|
+
end
|
|
69
71
|
end
|
|
70
72
|
end
|
|
71
73
|
end
|