volt 0.8.15 → 0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/Guardfile +2 -3
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +1 -1
- data/app/volt/tasks/live_query/data_store.rb +7 -7
- data/app/volt/tasks/live_query/live_query.rb +7 -9
- data/app/volt/tasks/live_query/live_query_pool.rb +13 -12
- data/app/volt/tasks/live_query/query_tracker.rb +4 -5
- data/app/volt/tasks/query_tasks.rb +9 -11
- data/app/volt/tasks/store_tasks.rb +4 -4
- data/app/volt/tasks/user_tasks.rb +1 -1
- data/bin/volt +2 -2
- data/lib/volt.rb +3 -7
- data/lib/volt/assets/test.rb +1 -2
- data/lib/volt/benchmark/benchmark.rb +3 -3
- data/lib/volt/boot.rb +1 -1
- data/lib/volt/cli.rb +18 -18
- data/lib/volt/cli/asset_compile.rb +8 -10
- data/lib/volt/cli/generate.rb +9 -11
- data/lib/volt/cli/new_gem.rb +51 -51
- data/lib/volt/config.rb +2 -3
- data/lib/volt/console.rb +1 -1
- data/lib/volt/controllers/model_controller.rb +6 -6
- data/lib/volt/data_stores/data_store.rb +1 -1
- data/lib/volt/data_stores/mongo_driver.rb +1 -1
- data/lib/volt/extra_core/array.rb +2 -2
- data/lib/volt/extra_core/blank.rb +1 -2
- data/lib/volt/extra_core/extra_core.rb +1 -1
- data/lib/volt/extra_core/inflector/methods.rb +0 -1
- data/lib/volt/extra_core/logger.rb +13 -7
- data/lib/volt/extra_core/numeric.rb +1 -1
- data/lib/volt/extra_core/string.rb +7 -7
- data/lib/volt/extra_core/stringify_keys.rb +5 -5
- data/lib/volt/models.rb +2 -2
- data/lib/volt/models/array_model.rb +18 -19
- data/lib/volt/models/cursor.rb +0 -1
- data/lib/volt/models/model.rb +17 -35
- data/lib/volt/models/model_hash_behaviour.rb +0 -2
- data/lib/volt/models/model_state.rb +1 -1
- data/lib/volt/models/model_wrapper.rb +1 -1
- data/lib/volt/models/persistors/array_store.rb +26 -13
- data/lib/volt/models/persistors/base.rb +1 -1
- data/lib/volt/models/persistors/flash.rb +2 -2
- data/lib/volt/models/persistors/local_store.rb +2 -3
- data/lib/volt/models/persistors/model_store.rb +7 -6
- data/lib/volt/models/persistors/params.rb +2 -2
- data/lib/volt/models/persistors/query/query_listener.rb +2 -0
- data/lib/volt/models/persistors/query/query_listener_pool.rb +1 -1
- data/lib/volt/models/persistors/store.rb +1 -2
- data/lib/volt/models/persistors/store_state.rb +2 -3
- data/lib/volt/models/url.rb +17 -16
- data/lib/volt/models/validations.rb +11 -14
- data/lib/volt/models/validators/length_validator.rb +3 -3
- data/lib/volt/models/validators/presence_validator.rb +2 -2
- data/lib/volt/page/bindings/attribute_binding.rb +2 -3
- data/lib/volt/page/bindings/base_binding.rb +1 -1
- data/lib/volt/page/bindings/each_binding.rb +8 -9
- data/lib/volt/page/bindings/event_binding.rb +2 -3
- data/lib/volt/page/bindings/template_binding.rb +8 -7
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +2 -1
- data/lib/volt/page/channel.rb +10 -10
- data/lib/volt/page/channel_stub.rb +1 -1
- data/lib/volt/page/document.rb +0 -1
- data/lib/volt/page/document_events.rb +4 -4
- data/lib/volt/page/page.rb +26 -19
- data/lib/volt/page/string_template_renderer.rb +2 -2
- data/lib/volt/page/sub_context.rb +10 -4
- data/lib/volt/page/targets/attribute_section.rb +1 -1
- data/lib/volt/page/targets/attribute_target.rb +1 -2
- data/lib/volt/page/targets/base_section.rb +4 -4
- data/lib/volt/page/targets/binding_document/base_node.rb +0 -1
- data/lib/volt/page/targets/binding_document/component_node.rb +4 -5
- data/lib/volt/page/targets/dom_section.rb +21 -22
- data/lib/volt/page/targets/dom_target.rb +1 -1
- data/lib/volt/page/targets/dom_template.rb +11 -12
- data/lib/volt/page/targets/helpers/comment_searchers.rb +7 -8
- data/lib/volt/page/tasks.rb +0 -1
- data/lib/volt/page/template_renderer.rb +1 -1
- data/lib/volt/page/url_tracker.rb +3 -3
- data/lib/volt/reactive/computation.rb +5 -11
- data/lib/volt/reactive/dependency.rb +1 -3
- data/lib/volt/reactive/eventable.rb +17 -4
- data/lib/volt/reactive/hash_dependency.rb +1 -0
- data/lib/volt/reactive/reactive_accessors.rb +0 -1
- data/lib/volt/reactive/reactive_array.rb +20 -25
- data/lib/volt/reactive/reactive_hash.rb +3 -3
- data/lib/volt/router/routes.rb +11 -13
- data/lib/volt/server.rb +17 -17
- data/lib/volt/server/component_handler.rb +2 -2
- data/lib/volt/server/component_templates.rb +8 -8
- data/lib/volt/server/html_parser/attribute_scope.rb +9 -10
- data/lib/volt/server/html_parser/if_view_scope.rb +2 -2
- data/lib/volt/server/html_parser/sandlebars_parser.rb +14 -14
- data/lib/volt/server/html_parser/textarea_scope.rb +1 -2
- data/lib/volt/server/html_parser/view_handler.rb +1 -1
- data/lib/volt/server/html_parser/view_parser.rb +1 -1
- data/lib/volt/server/html_parser/view_scope.rb +10 -10
- data/lib/volt/server/rack/asset_files.rb +15 -16
- data/lib/volt/server/rack/component_code.rb +2 -2
- data/lib/volt/server/rack/component_html_renderer.rb +0 -1
- data/lib/volt/server/rack/component_paths.rb +13 -10
- data/lib/volt/server/rack/index_files.rb +4 -4
- data/lib/volt/server/rack/opal_files.rb +4 -5
- data/lib/volt/server/rack/source_map_server.rb +3 -3
- data/lib/volt/server/socket_connection_handler.rb +3 -4
- data/lib/volt/server/socket_connection_handler_stub.rb +1 -1
- data/lib/volt/spec/setup.rb +3 -3
- data/lib/volt/store/mongo.rb +2 -2
- data/lib/volt/tasks/task_handler.rb +3 -3
- data/lib/volt/utils/generic_counting_pool.rb +2 -2
- data/lib/volt/utils/generic_pool.rb +7 -8
- data/lib/volt/utils/local_storage.rb +4 -4
- data/lib/volt/volt/environment.rb +1 -1
- data/spec/apps/file_loading/app/shared/config/dependencies.rb +1 -1
- data/spec/apps/kitchen_sink/Gemfile +0 -2
- data/spec/apps/kitchen_sink/app/main/config/routes.rb +5 -5
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +7 -6
- data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +3 -4
- data/spec/controllers/reactive_accessors_spec.rb +4 -4
- data/spec/extra_core/inflector_spec.rb +1 -1
- data/spec/extra_core/string_transformation_test_cases.rb +23 -24
- data/spec/extra_core/string_transformations_spec.rb +11 -12
- data/spec/integration/bindings_spec.rb +15 -15
- data/spec/integration/list_spec.rb +12 -13
- data/spec/integration/templates_spec.rb +3 -3
- data/spec/models/model_spec.rb +74 -80
- data/spec/models/persistors/params_spec.rb +2 -2
- data/spec/models/persistors/store_spec.rb +4 -4
- data/spec/models/validations_spec.rb +14 -23
- data/spec/page/bindings/content_binding_spec.rb +7 -8
- data/spec/page/bindings/template_binding_spec.rb +22 -24
- data/spec/page/sub_context_spec.rb +2 -2
- data/spec/reactive/computation_spec.rb +3 -3
- data/spec/reactive/reactive_array_spec.rb +12 -12
- data/spec/router/routes_spec.rb +45 -48
- data/spec/server/html_parser/sandlebars_parser_spec.rb +42 -42
- data/spec/server/html_parser/view_parser_spec.rb +132 -153
- data/spec/server/rack/asset_files_spec.rb +9 -8
- data/spec/server/rack/component_paths_spec.rb +5 -5
- data/spec/server/rack/rack_requests_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/tasks/live_query_spec.rb +4 -5
- data/spec/tasks/query_tasks.rb +2 -4
- data/spec/tasks/query_tracker_spec.rb +29 -29
- data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
- data/spec/utils/generic_counting_pool_spec.rb +4 -4
- data/spec/utils/generic_pool_spec.rb +12 -12
- data/templates/component/config/routes.rb +2 -2
- data/templates/component/controllers/main_controller.rb +7 -6
- data/templates/newgem/app/newgem/config/dependencies.rb +1 -1
- data/templates/newgem/app/newgem/config/routes.rb +1 -1
- data/templates/project/app/main/config/routes.rb +2 -2
- data/templates/project/app/main/controllers/main_controller.rb +7 -6
- data/templates/project/spec/sample_spec.rb +2 -2
- data/volt.gemspec +32 -33
- metadata +3 -4
- data/lib/volt/extra_core/log.rb +0 -56
- data/lib/volt/extra_core/try.rb +0 -31
@@ -2,7 +2,7 @@ require 'volt/reactive/hash_dependency'
|
|
2
2
|
|
3
3
|
module Volt
|
4
4
|
class ReactiveHash
|
5
|
-
def initialize(values={})
|
5
|
+
def initialize(values = {})
|
6
6
|
@hash = values
|
7
7
|
@deps = HashDependency.new
|
8
8
|
@all_deps = Dependency.new
|
@@ -17,13 +17,13 @@ module Volt
|
|
17
17
|
def method_missing(method_name, *args, &block)
|
18
18
|
@all_deps.depend
|
19
19
|
|
20
|
-
|
20
|
+
@hash.send(method_name, *args, &block)
|
21
21
|
end
|
22
22
|
|
23
23
|
def [](key)
|
24
24
|
@deps.depend(key)
|
25
25
|
|
26
|
-
|
26
|
+
@hash[key]
|
27
27
|
end
|
28
28
|
|
29
29
|
def []=(key, value)
|
data/lib/volt/router/routes.rb
CHANGED
@@ -53,11 +53,11 @@ module Volt
|
|
53
53
|
def define(&block)
|
54
54
|
instance_eval(&block)
|
55
55
|
|
56
|
-
|
56
|
+
self
|
57
57
|
end
|
58
58
|
|
59
59
|
# Add a route
|
60
|
-
def get(path, params={})
|
60
|
+
def get(path, params = {})
|
61
61
|
params = params.symbolize_keys
|
62
62
|
if has_binding?(path)
|
63
63
|
add_indirect_path(path, params)
|
@@ -88,7 +88,7 @@ module Volt
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
[nil, nil]
|
92
92
|
end
|
93
93
|
|
94
94
|
# Takes in a path and returns the matching params.
|
@@ -105,6 +105,7 @@ module Volt
|
|
105
105
|
end
|
106
106
|
|
107
107
|
private
|
108
|
+
|
108
109
|
# Recursively walk the @indirect_routes hash, return the params for a route, return
|
109
110
|
# false for non-matches.
|
110
111
|
def match_path(original_parts, remaining_parts, node)
|
@@ -114,7 +115,7 @@ module Volt
|
|
114
115
|
# really I just got lucky)
|
115
116
|
part, *parts = remaining_parts
|
116
117
|
|
117
|
-
if part
|
118
|
+
if part.nil?
|
118
119
|
if node[part]
|
119
120
|
# We found a match, replace the bindings and return
|
120
121
|
# TODO: Handvle nested
|
@@ -144,10 +145,9 @@ module Volt
|
|
144
145
|
end
|
145
146
|
end
|
146
147
|
|
147
|
-
|
148
|
+
params
|
148
149
|
end
|
149
150
|
|
150
|
-
|
151
151
|
# Build up the @indirect_routes data structure.
|
152
152
|
# '*' means wildcard match anything
|
153
153
|
# nil means a terminal, who's value will be the params.
|
@@ -172,7 +172,6 @@ module Volt
|
|
172
172
|
node[nil] = params
|
173
173
|
end
|
174
174
|
|
175
|
-
|
176
175
|
def add_param_matcher(path, params)
|
177
176
|
params = params.dup
|
178
177
|
parts = url_parts(path)
|
@@ -194,7 +193,7 @@ module Volt
|
|
194
193
|
# a url with the bindings filled in, and params with the binding params
|
195
194
|
# removed. (So the remaining can be added onto the end of the url ?params1=...)
|
196
195
|
def create_path_transformer(parts)
|
197
|
-
|
196
|
+
lambda do |input_params|
|
198
197
|
input_params = input_params.dup
|
199
198
|
|
200
199
|
url = parts.map do |part|
|
@@ -234,8 +233,8 @@ module Volt
|
|
234
233
|
# test_params did not have matching key
|
235
234
|
return false
|
236
235
|
end
|
237
|
-
elsif value
|
238
|
-
unless test_params.
|
236
|
+
elsif value.nil?
|
237
|
+
unless test_params.key?(key)
|
239
238
|
return false
|
240
239
|
end
|
241
240
|
else
|
@@ -247,14 +246,13 @@ module Volt
|
|
247
246
|
end
|
248
247
|
end
|
249
248
|
|
250
|
-
|
249
|
+
[true, test_params]
|
251
250
|
end
|
252
251
|
|
253
252
|
def url_parts(path)
|
254
|
-
|
253
|
+
path.split('/').reject(&:blank?)
|
255
254
|
end
|
256
255
|
|
257
|
-
|
258
256
|
# Check if a string has a binding in it
|
259
257
|
def has_binding?(string)
|
260
258
|
string.index('{{') && string.index('}}')
|
data/lib/volt/server.rb
CHANGED
@@ -7,13 +7,13 @@ else
|
|
7
7
|
require 'thin'
|
8
8
|
end
|
9
9
|
|
10
|
-
require
|
10
|
+
require 'rack'
|
11
11
|
if RUBY_PLATFORM != 'java'
|
12
|
-
require
|
13
|
-
require
|
12
|
+
require 'rack/sockjs'
|
13
|
+
require 'eventmachine'
|
14
14
|
end
|
15
|
-
require
|
16
|
-
require
|
15
|
+
require 'sass'
|
16
|
+
require 'sprockets-sass'
|
17
17
|
require 'listen'
|
18
18
|
|
19
19
|
require 'volt'
|
@@ -52,11 +52,11 @@ end
|
|
52
52
|
|
53
53
|
module Volt
|
54
54
|
class Server
|
55
|
-
def initialize(root_path=nil)
|
55
|
+
def initialize(root_path = nil)
|
56
56
|
root_path ||= Dir.pwd
|
57
57
|
Volt.root = root_path
|
58
58
|
|
59
|
-
@app_path = File.expand_path(File.join(root_path,
|
59
|
+
@app_path = File.expand_path(File.join(root_path, 'app'))
|
60
60
|
|
61
61
|
# Boot the volt app
|
62
62
|
@component_paths = Volt.boot(root_path)
|
@@ -67,13 +67,13 @@ module Volt
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def display_welcome
|
70
|
-
puts File.read(File.join(File.dirname(__FILE__),
|
70
|
+
puts File.read(File.join(File.dirname(__FILE__), 'server/banner.txt'))
|
71
71
|
end
|
72
72
|
|
73
73
|
def setup_change_listener
|
74
74
|
# Setup the listeners for file changes
|
75
75
|
listener = Listen.to("#{@app_path}/") do |modified, added, removed|
|
76
|
-
puts
|
76
|
+
puts 'file changed, sending reload'
|
77
77
|
SocketConnectionHandler.send_message_all(nil, 'reload')
|
78
78
|
end
|
79
79
|
listener.start
|
@@ -115,20 +115,20 @@ module Volt
|
|
115
115
|
if RUBY_PLATFORM != 'java'
|
116
116
|
SocketConnectionHandler.dispatcher = Dispatcher.new
|
117
117
|
|
118
|
-
@app.map
|
119
|
-
run Rack::SockJS.new(SocketConnectionHandler)
|
118
|
+
@app.map '/channel' do
|
119
|
+
run Rack::SockJS.new(SocketConnectionHandler) # , :websocket => false
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
@app.use Rack::Static,
|
124
|
-
:
|
125
|
-
:
|
126
|
-
:
|
127
|
-
:
|
128
|
-
|
124
|
+
urls: ['/'],
|
125
|
+
root: 'public',
|
126
|
+
index: '',
|
127
|
+
header_rules: [
|
128
|
+
[:all, { 'Cache-Control' => 'public, max-age=86400' }]
|
129
129
|
]
|
130
130
|
|
131
|
-
@app.run lambda { |env| [404, {'Content-Type' => 'text/html; charset=utf-8'}, ['404 - page not found']] }
|
131
|
+
@app.run lambda { |env| [404, { 'Content-Type' => 'text/html; charset=utf-8' }, ['404 - page not found']] }
|
132
132
|
|
133
133
|
@app
|
134
134
|
end
|
@@ -16,7 +16,7 @@ module Volt
|
|
16
16
|
|
17
17
|
javascript_code = compile_for_component(component_name)
|
18
18
|
|
19
|
-
|
19
|
+
[200, { 'Content-Type' => 'application/javascript; charset=utf-8' }, StringIO.new(javascript_code)]
|
20
20
|
end
|
21
21
|
|
22
22
|
def compile_for_component(component_name)
|
@@ -28,7 +28,7 @@ module Volt
|
|
28
28
|
# Compile the code
|
29
29
|
javascript_code = Opal.compile(code)
|
30
30
|
|
31
|
-
|
31
|
+
javascript_code
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -4,7 +4,7 @@ require 'volt/server/html_parser/view_parser'
|
|
4
4
|
# setup code (for controllers, models, views, and routes)
|
5
5
|
module Volt
|
6
6
|
class ComponentTemplates
|
7
|
-
def initialize(component_path, component_name, client=true)
|
7
|
+
def initialize(component_path, component_name, client = true)
|
8
8
|
@component_path = component_path
|
9
9
|
@component_name = component_name
|
10
10
|
@client = true
|
@@ -17,7 +17,7 @@ module Volt
|
|
17
17
|
code << generate_controller_code + generate_model_code + generate_routes_code + generate_tasks_code
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
code
|
21
21
|
end
|
22
22
|
|
23
23
|
def page_reference
|
@@ -56,7 +56,7 @@ module Volt
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
code
|
60
60
|
end
|
61
61
|
|
62
62
|
def generate_controller_code
|
@@ -67,7 +67,7 @@ module Volt
|
|
67
67
|
code << File.read(controller_path) + "\n\n"
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
code
|
71
71
|
end
|
72
72
|
|
73
73
|
def generate_model_code
|
@@ -82,24 +82,24 @@ module Volt
|
|
82
82
|
code << "#{page_reference}.add_model(#{model_name.inspect})\n\n"
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
code
|
86
86
|
end
|
87
87
|
|
88
88
|
def generate_routes_code
|
89
89
|
code = ''
|
90
90
|
routes_path = "#{@component_path}/config/routes.rb"
|
91
91
|
|
92
|
-
if File.
|
92
|
+
if File.exist?(routes_path)
|
93
93
|
code << "#{page_reference}.add_routes do\n"
|
94
94
|
code << "\n" + File.read(routes_path) + "\n"
|
95
95
|
code << "end\n\n"
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
code
|
99
99
|
end
|
100
100
|
|
101
101
|
def generate_tasks_code
|
102
|
-
|
102
|
+
TaskHandler.known_handlers.map do |handler|
|
103
103
|
"class #{handler.name} < Volt::TaskHandler; end"
|
104
104
|
end.join "\n"
|
105
105
|
end
|
@@ -13,7 +13,7 @@ module Volt
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
new_attributes
|
17
17
|
end
|
18
18
|
|
19
19
|
def process_event_binding(tag_name, attributes, name, value)
|
@@ -38,7 +38,7 @@ module Volt
|
|
38
38
|
parts = value.split(/(\{\{[^\}]+\}\})/).reject(&:blank?)
|
39
39
|
binding_count = parts.count { |p| p[0] == '{' && p[1] == '{' && p[-2] == '}' && p[-1] == '}' }
|
40
40
|
|
41
|
-
|
41
|
+
[parts, binding_count]
|
42
42
|
end
|
43
43
|
|
44
44
|
def process_attribute(tag_name, attributes, attribute_name, value)
|
@@ -73,7 +73,7 @@ module Volt
|
|
73
73
|
prefix = 'self.'
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
"#{prefix}#{getter}=(val)"
|
77
77
|
end
|
78
78
|
|
79
79
|
# Add an attribute binding on the tag, bind directly to the getter in the binding
|
@@ -89,16 +89,15 @@ module Volt
|
|
89
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
90
|
end
|
91
91
|
|
92
|
-
|
93
92
|
def add_multiple_attribute(tag_name, id, attribute_name, parts, content)
|
94
93
|
case attribute_name
|
95
94
|
when 'checked', 'value'
|
96
95
|
if parts.size > 1
|
97
96
|
if tag_name == 'textarea'
|
98
|
-
|
97
|
+
fail "The content of text area's can not be bound to multiple bindings."
|
99
98
|
else
|
100
99
|
# Multiple values can not be passed to value or checked attributes.
|
101
|
-
|
100
|
+
fail "Multiple bindings can not be passed to a #{attribute_name} binding: #{parts.inspect}"
|
102
101
|
end
|
103
102
|
end
|
104
103
|
end
|
@@ -123,24 +122,24 @@ module Volt
|
|
123
122
|
@handler.templates[key] = value
|
124
123
|
end
|
125
124
|
|
126
|
-
|
125
|
+
path
|
127
126
|
end
|
128
127
|
|
129
128
|
def add_id_to_attributes(attributes)
|
130
129
|
id = attributes['id'] ||= "id#{@binding_number}"
|
131
130
|
@binding_number += 1
|
132
131
|
|
133
|
-
|
132
|
+
id.to_s
|
134
133
|
end
|
135
134
|
|
136
135
|
def attribute_string(attributes)
|
137
136
|
attr_str = attributes.map { |v| "#{v[0]}=\"#{v[1]}\"" }.join(' ')
|
138
137
|
if attr_str.size > 0
|
139
138
|
# extra space
|
140
|
-
attr_str =
|
139
|
+
attr_str = ' ' + attr_str
|
141
140
|
end
|
142
141
|
|
143
|
-
|
142
|
+
attr_str
|
144
143
|
end
|
145
144
|
end
|
146
145
|
end
|
@@ -42,7 +42,7 @@ module Volt
|
|
42
42
|
new_path
|
43
43
|
end
|
44
44
|
|
45
|
-
def close_scope(final=true)
|
45
|
+
def close_scope(final = true)
|
46
46
|
@branches << [@last_content, path]
|
47
47
|
|
48
48
|
super()
|
@@ -51,7 +51,7 @@ module Volt
|
|
51
51
|
# Add the binding to the parent
|
52
52
|
branches = @branches.map do |branch|
|
53
53
|
content = branch[0]
|
54
|
-
if content
|
54
|
+
if content.nil?
|
55
55
|
content = nil.inspect
|
56
56
|
else
|
57
57
|
content = "Proc.new { #{branch[0]} }"
|
@@ -16,7 +16,7 @@ module Volt
|
|
16
16
|
hash = {}
|
17
17
|
array.each { |v| hash[v] = true }
|
18
18
|
|
19
|
-
|
19
|
+
hash
|
20
20
|
end
|
21
21
|
|
22
22
|
# regex matchers
|
@@ -25,15 +25,15 @@ module Volt
|
|
25
25
|
ATTRIBUTES = /([-\:A-Za-z0-9_]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/
|
26
26
|
|
27
27
|
# Types of elements
|
28
|
-
BLOCK = truth_hash(%w
|
29
|
-
EMPTY = truth_hash(%w
|
30
|
-
INLINE = truth_hash(%w
|
31
|
-
CLOSE_SELF = truth_hash(%w
|
32
|
-
SPECIAL = truth_hash(%w
|
28
|
+
BLOCK = truth_hash(%w(a address applet blockquote button center dd del dir div dl dt fieldset form frameset hr iframe ins isindex li map menu noframes noscript object ol p pre script table tbody td tfoot th thead tr ul))
|
29
|
+
EMPTY = truth_hash(%w(area base basefont br col frame hr img input isindex link meta param embed))
|
30
|
+
INLINE = truth_hash(%w(abbr acronym applet b basefont bdo big br button cite code del dfn em font i iframe img input ins kbd label map object q s samp script select small span strike strong sub sup textarea tt u var))
|
31
|
+
CLOSE_SELF = truth_hash(%w(colgroup dd dt li options p td tfoot th thead tr))
|
32
|
+
SPECIAL = truth_hash(%w(script style))
|
33
33
|
|
34
|
-
FILL_IN_ATTRIBUTES = truth_hash(%w
|
34
|
+
FILL_IN_ATTRIBUTES = truth_hash(%w(checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected))
|
35
35
|
|
36
|
-
def initialize(html, handler, file_path=nil)
|
36
|
+
def initialize(html, handler, file_path = nil)
|
37
37
|
@html = StringScanner.new(html)
|
38
38
|
@handler = handler
|
39
39
|
@file_path = file_path
|
@@ -122,7 +122,7 @@ module Volt
|
|
122
122
|
# or end of doc before closed binding
|
123
123
|
raise_parse_error("unclosed binding: {#{binding.strip}")
|
124
124
|
else
|
125
|
-
|
125
|
+
fail 'should not reach here'
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -136,7 +136,7 @@ module Volt
|
|
136
136
|
error_str = error + " on line: #{line_number}"
|
137
137
|
error_str += " of #{@file_path}" if @file_path
|
138
138
|
|
139
|
-
|
139
|
+
fail HTMLParseError, error_str
|
140
140
|
end
|
141
141
|
|
142
142
|
def start_tag(tag, tag_name, rest, unary)
|
@@ -197,7 +197,7 @@ module Volt
|
|
197
197
|
|
198
198
|
if tag
|
199
199
|
# Find the closest tag that closes.
|
200
|
-
(@stack.size-1).downto(0) do |index|
|
200
|
+
(@stack.size - 1).downto(0) do |index|
|
201
201
|
if @stack[index] == tag_name
|
202
202
|
new_size = index
|
203
203
|
break
|
@@ -207,7 +207,7 @@ module Volt
|
|
207
207
|
|
208
208
|
if new_size >= 0
|
209
209
|
if @handler.respond_to?(:end_tag)
|
210
|
-
(@stack.size-1).downto(new_size) do |index|
|
210
|
+
(@stack.size - 1).downto(new_size) do |index|
|
211
211
|
@handler.end_tag(@stack[index])
|
212
212
|
end
|
213
213
|
end
|
@@ -217,9 +217,9 @@ module Volt
|
|
217
217
|
end
|
218
218
|
|
219
219
|
def special_tag(close_tag, body)
|
220
|
-
body = body[0..((-1 * close_tag.size)-1)]
|
220
|
+
body = body[0..((-1 * close_tag.size) - 1)]
|
221
221
|
|
222
|
-
body = body.gsub(/\<\!--(.*?)--\>/,
|
222
|
+
body = body.gsub(/\<\!--(.*?)--\>/, '\\1').gsub(/\<\!\[CDATA\[(.*?)\]\]\>/, '\\1')
|
223
223
|
|
224
224
|
text(body)
|
225
225
|
|
@@ -10,7 +10,7 @@ module Volt
|
|
10
10
|
@html << "{{#{content}}}"
|
11
11
|
end
|
12
12
|
|
13
|
-
def close_scope(pop=true)
|
13
|
+
def close_scope(pop = true)
|
14
14
|
# Remove from the scope
|
15
15
|
@handler.scope.pop
|
16
16
|
|
@@ -27,7 +27,6 @@ module Volt
|
|
27
27
|
attributes = @handler.last.process_attributes('textarea', attributes)
|
28
28
|
|
29
29
|
@handler.last.html << "<textarea#{attribute_string(attributes)}>#{@html}</textarea>"
|
30
|
-
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|