volt 0.8.14 → 0.8.15

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