volt 0.8.15 → 0.8.16
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/.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
|
@@ -24,10 +24,10 @@ class HTMLHandler
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def start_tag(tag_name, attributes, unary)
|
|
27
|
-
attr_str = attributes.map {|v| "#{v[0]}=\"#{v[1]}\"" }.join(' ')
|
|
27
|
+
attr_str = attributes.map { |v| "#{v[0]}=\"#{v[1]}\"" }.join(' ')
|
|
28
28
|
if attr_str.size > 0
|
|
29
29
|
# extra space
|
|
30
|
-
attr_str =
|
|
30
|
+
attr_str = ' ' + attr_str
|
|
31
31
|
end
|
|
32
32
|
@html << "<#{tag_name}#{attr_str}#{unary ? ' /' : ''}>"
|
|
33
33
|
end
|
|
@@ -43,88 +43,88 @@ def parse_url(url)
|
|
|
43
43
|
|
|
44
44
|
# html = File.read("/Users/ryanstout/Desktop/tests/#{url}1.html")
|
|
45
45
|
|
|
46
|
-
File.open("/Users/ryanstout/Desktop/tests/#{url}1.html", 'w') {|f| f.write(html) }
|
|
46
|
+
File.open("/Users/ryanstout/Desktop/tests/#{url}1.html", 'w') { |f| f.write(html) }
|
|
47
47
|
|
|
48
48
|
handler = HTMLHandler.new
|
|
49
49
|
Volt::SandlebarsParser.new(html, handler)
|
|
50
50
|
|
|
51
|
-
File.open("/Users/ryanstout/Desktop/tests/#{url}2.html", 'w') {|f| f.write(handler.html) }
|
|
51
|
+
File.open("/Users/ryanstout/Desktop/tests/#{url}2.html", 'w') { |f| f.write(handler.html) }
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
describe Volt::SandlebarsParser do
|
|
55
|
-
def test_html(html, match=nil)
|
|
55
|
+
def test_html(html, match = nil)
|
|
56
56
|
handler = HTMLHandler.new
|
|
57
57
|
parser = Volt::SandlebarsParser.new(html, handler)
|
|
58
58
|
|
|
59
59
|
expect(handler.html).to eq(match || html)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
it
|
|
63
|
-
html =
|
|
62
|
+
it 'should handle a doctype' do
|
|
63
|
+
html = '<!DOCTYPE html><p>text</p>'
|
|
64
64
|
|
|
65
65
|
test_html(html)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
it
|
|
69
|
-
html =
|
|
68
|
+
it 'should parse comments' do
|
|
69
|
+
html = '<!-- my comment -->'
|
|
70
70
|
test_html(html)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
it
|
|
74
|
-
html =
|
|
73
|
+
it 'should handle text' do
|
|
74
|
+
html = 'some text, <!-- a comment -->, some more text'
|
|
75
75
|
test_html(html)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
it
|
|
78
|
+
it 'should handle tags' do
|
|
79
79
|
html = "<a name=\"cool\"></a>"
|
|
80
80
|
test_html(html)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
it
|
|
84
|
-
html =
|
|
85
|
-
match =
|
|
83
|
+
it 'should close tags' do
|
|
84
|
+
html = '<div><p>test</p>'
|
|
85
|
+
match = '<div><p>test</p></div>'
|
|
86
86
|
|
|
87
87
|
test_html(html, match)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
it
|
|
91
|
-
html =
|
|
92
|
-
match =
|
|
90
|
+
it 'should handle a script tag with html in it' do
|
|
91
|
+
html = '<script><!-- some js code <a>cool</a> here --></script>'
|
|
92
|
+
match = '<script> some js code <a>cool</a> here </script>'
|
|
93
93
|
test_html(html, match)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
it
|
|
97
|
-
html =
|
|
96
|
+
it 'should handle bindings' do
|
|
97
|
+
html = '<p>some cool {text} is {awesome}</p>'
|
|
98
98
|
test_html(html)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
it
|
|
101
|
+
it 'should handle bindings with nested { and }' do
|
|
102
102
|
html = "<p>testing with {nested { 'binding stuff' }}</p>"
|
|
103
103
|
test_html(html)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
it
|
|
107
|
-
html =
|
|
106
|
+
it 'should raise an exception on an unclosed binding at the end of the document' do
|
|
107
|
+
html = '<p>testing with {{nested'
|
|
108
108
|
|
|
109
109
|
handler = HTMLHandler.new
|
|
110
110
|
expect { Volt::SandlebarsParser.new(html, handler) }.to raise_error(Volt::HTMLParseError)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
it
|
|
113
|
+
it 'should raise an exception on an unclosed binding' do
|
|
114
114
|
html = "<p>testing with {{nested </p>\n<p>ok</p>"
|
|
115
115
|
|
|
116
116
|
handler = HTMLHandler.new
|
|
117
117
|
expect { Volt::SandlebarsParser.new(html, handler) }.to raise_error(Volt::HTMLParseError)
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
it
|
|
120
|
+
it 'should report the line number' do
|
|
121
121
|
html = "\n\n<p>some paragraph</p>\n\n<p>testing with {{nested </p>\n<p>ok</p>"
|
|
122
122
|
|
|
123
123
|
handler = HTMLHandler.new
|
|
124
|
-
expect { Volt::SandlebarsParser.new(html, handler) }.to raise_error(Volt::HTMLParseError,
|
|
124
|
+
expect { Volt::SandlebarsParser.new(html, handler) }.to raise_error(Volt::HTMLParseError, 'unclosed binding: {nested </p> on line: 5')
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
it
|
|
127
|
+
it 'should handle a bunch of things' do
|
|
128
128
|
html = <<-END
|
|
129
129
|
<p class="some class">This is my text <a href="something.com">something.com</a></p>
|
|
130
130
|
END
|
|
@@ -132,50 +132,50 @@ describe Volt::SandlebarsParser do
|
|
|
132
132
|
test_html(html)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
it
|
|
135
|
+
it 'should not jump between script tags' do
|
|
136
136
|
html = "\n<script>some text</script>\n\n<script>inside 2</script>\n"
|
|
137
137
|
|
|
138
138
|
test_html(html)
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
-
it
|
|
142
|
-
html =
|
|
141
|
+
it 'should not jump bindings' do
|
|
142
|
+
html = '<p>{some} text {binding}</p>'
|
|
143
143
|
test_html(html)
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
it
|
|
147
|
-
html =
|
|
148
|
-
match =
|
|
146
|
+
it 'should handle escaping things in a tripple escape' do
|
|
147
|
+
html = 'this is my {{{ tripple escape }}}'
|
|
148
|
+
match = 'this is my tripple escape '
|
|
149
149
|
test_html(html, match)
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
-
it
|
|
153
|
-
html =
|
|
154
|
-
match =
|
|
152
|
+
it 'should let you escape { and }' do
|
|
153
|
+
html = 'should escape {{{{}}} and {{{}}}}'
|
|
154
|
+
match = 'should escape { and }'
|
|
155
155
|
test_html(html, match)
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
-
it
|
|
158
|
+
it 'should handle sandlebar tags' do
|
|
159
159
|
html = "custom tag <:awesome name=\"yes\" />"
|
|
160
160
|
test_html(html)
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
it
|
|
163
|
+
it 'should keep the text after script' do
|
|
164
164
|
html = "<ul><li>\n\n<script>\n\nsome js code\n\nmore\n\n</script> \n </li> \n \n </ul>"
|
|
165
165
|
test_html(html)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
|
-
it
|
|
168
|
+
it 'should handle dashes in attributes' do
|
|
169
169
|
html = "<form accept-charset=\"UTF-8\"></form>"
|
|
170
170
|
test_html(html)
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
-
it
|
|
173
|
+
it 'should handle conditional comments for IE' do
|
|
174
174
|
html = "<!--[if ie6]>some ie only stuff<![endif]-->\n<br />"
|
|
175
175
|
test_html(html)
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
-
it
|
|
178
|
+
it 'should be fast' do
|
|
179
179
|
html = File.read(File.join(File.dirname(__FILE__), 'sample_page.html'))
|
|
180
180
|
handler = HTMLHandler.new
|
|
181
181
|
time = Benchmark.measure do
|
|
@@ -186,7 +186,7 @@ describe Volt::SandlebarsParser do
|
|
|
186
186
|
expect(time.total).to be < 0.1
|
|
187
187
|
end
|
|
188
188
|
|
|
189
|
-
it
|
|
189
|
+
it 'should parse nested components' do
|
|
190
190
|
html = "custom tag <:awesome:cool name=\"yes\" />"
|
|
191
191
|
test_html(html)
|
|
192
192
|
end
|
|
@@ -4,23 +4,21 @@ require 'benchmark'
|
|
|
4
4
|
require 'volt/server/html_parser/view_parser'
|
|
5
5
|
|
|
6
6
|
describe Volt::ViewParser do
|
|
7
|
-
it
|
|
8
|
-
html =
|
|
9
|
-
|
|
10
|
-
view = Volt::ViewParser.new(html,
|
|
11
|
-
|
|
12
|
-
expect(view.templates).to eq({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
})
|
|
7
|
+
it 'should parse content bindings' do
|
|
8
|
+
html = '<p>Some {{ content }} binding, {{ name }}</p>'
|
|
9
|
+
|
|
10
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
11
|
+
|
|
12
|
+
expect(view.templates).to eq('main/main/main/body' => {
|
|
13
|
+
'html' => '<p>Some <!-- $0 --><!-- $/0 --> binding, <!-- $1 --><!-- $/1 --></p>',
|
|
14
|
+
'bindings' => {
|
|
15
|
+
0 => ['lambda { |__p, __t, __c, __id| Volt::ContentBinding.new(__p, __t, __c, __id, Proc.new { content }) }'],
|
|
16
|
+
1 => ['lambda { |__p, __t, __c, __id| Volt::ContentBinding.new(__p, __t, __c, __id, Proc.new { name }) }']
|
|
17
|
+
}
|
|
18
|
+
})
|
|
21
19
|
end
|
|
22
20
|
|
|
23
|
-
it
|
|
21
|
+
it 'should parse if bindings' do
|
|
24
22
|
html = <<-END
|
|
25
23
|
<p>
|
|
26
24
|
Some
|
|
@@ -34,28 +32,25 @@ describe Volt::ViewParser do
|
|
|
34
32
|
</p>
|
|
35
33
|
END
|
|
36
34
|
|
|
37
|
-
view = Volt::ViewParser.new(html,
|
|
38
|
-
|
|
39
|
-
expect(view.templates).to eq(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
35
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
36
|
+
|
|
37
|
+
expect(view.templates).to eq('main/main/main/body/__ifg0/__if0' => {
|
|
38
|
+
'html' => "\n text\n "
|
|
39
|
+
},
|
|
40
|
+
'main/main/main/body/__ifg0/__if1' => {
|
|
41
|
+
'html' => "\n <button>Button</button>\n "
|
|
42
|
+
},
|
|
43
|
+
'main/main/main/body/__ifg0/__if2' => {
|
|
44
|
+
'html' => "\n <a href=\"\">link</a>\n "
|
|
45
|
+
},
|
|
46
|
+
'main/main/main/body' => {
|
|
47
|
+
'html' => " <p>\n Some\n <!-- $0 --><!-- $/0 -->\n </p>\n",
|
|
48
|
+
'bindings' => {
|
|
49
|
+
0 => [
|
|
50
|
+
"lambda { |__p, __t, __c, __id| Volt::IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"main/main/main/body/__ifg0/__if0\"], [Proc.new { showing == :button }, \"main/main/main/body/__ifg0/__if1\"], [nil, \"main/main/main/body/__ifg0/__if2\"]]) }"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
})
|
|
59
54
|
|
|
60
55
|
end
|
|
61
56
|
|
|
@@ -73,36 +68,33 @@ describe Volt::ViewParser do
|
|
|
73
68
|
</p>
|
|
74
69
|
END
|
|
75
70
|
|
|
76
|
-
view = Volt::ViewParser.new(html,
|
|
77
|
-
|
|
78
|
-
expect(view.templates).to eq(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
})
|
|
71
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
72
|
+
|
|
73
|
+
expect(view.templates).to eq('main/main/main/body/__ifg0/__if0/__ifg0/__if0' => {
|
|
74
|
+
'html' => "\n sub item text\n "
|
|
75
|
+
},
|
|
76
|
+
'main/main/main/body/__ifg0/__if0' => {
|
|
77
|
+
'html' => "\n <!-- $0 --><!-- $/0 -->\n ",
|
|
78
|
+
'bindings' => {
|
|
79
|
+
0 => [
|
|
80
|
+
"lambda { |__p, __t, __c, __id| Volt::IfBinding.new(__p, __t, __c, __id, [[Proc.new { sub_item }, \"main/main/main/body/__ifg0/__if0/__ifg0/__if0\"]]) }"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
'main/main/main/body/__ifg0/__if1' => {
|
|
85
|
+
'html' => "\n other\n "
|
|
86
|
+
},
|
|
87
|
+
'main/main/main/body' => {
|
|
88
|
+
'html' => " <p>\n Some\n <!-- $0 --><!-- $/0 -->\n </p>\n",
|
|
89
|
+
'bindings' => {
|
|
90
|
+
0 => [
|
|
91
|
+
"lambda { |__p, __t, __c, __id| Volt::IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"main/main/main/body/__ifg0/__if0\"], [nil, \"main/main/main/body/__ifg0/__if1\"]]) }"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
})
|
|
102
95
|
end
|
|
103
96
|
|
|
104
|
-
|
|
105
|
-
it "should parse each bindings" do
|
|
97
|
+
it 'should parse each bindings' do
|
|
106
98
|
html = <<-END
|
|
107
99
|
<div class="main">
|
|
108
100
|
{{ _items.each do |item| }}
|
|
@@ -111,116 +103,108 @@ describe Volt::ViewParser do
|
|
|
111
103
|
</div>
|
|
112
104
|
END
|
|
113
105
|
|
|
114
|
-
view = Volt::ViewParser.new(html,
|
|
115
|
-
|
|
116
|
-
expect(view.templates).to eq({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"main
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
|
|
106
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
107
|
+
|
|
108
|
+
expect(view.templates).to eq('main/main/main/body/__each0/__template/0' => {
|
|
109
|
+
'html' => "\n <p><!-- $0 --><!-- $/0 --></p>\n ",
|
|
110
|
+
'bindings' => {
|
|
111
|
+
0 => [
|
|
112
|
+
'lambda { |__p, __t, __c, __id| Volt::ContentBinding.new(__p, __t, __c, __id, Proc.new { item }) }'
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
'main/main/main/body' => {
|
|
117
|
+
'html' => " <div class=\"main\">\n <!-- $0 --><!-- $/0 -->\n </div>\n",
|
|
118
|
+
'bindings' => {
|
|
119
|
+
0 => [
|
|
120
|
+
"lambda { |__p, __t, __c, __id| Volt::EachBinding.new(__p, __t, __c, __id, Proc.new { _items }, \"item\", \"main/main/main/body/__each0/__template/0\") }"
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
})
|
|
135
124
|
|
|
136
125
|
end
|
|
137
126
|
|
|
138
|
-
it
|
|
127
|
+
it 'should parse a single attribute binding' do
|
|
139
128
|
html = <<-END
|
|
140
129
|
<div class="{{ main_class }}">
|
|
141
130
|
</div>
|
|
142
131
|
END
|
|
143
132
|
|
|
144
|
-
view = Volt::ViewParser.new(html,
|
|
133
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
145
134
|
|
|
146
|
-
expect(view.templates).to eq(
|
|
135
|
+
expect(view.templates).to eq('main/main/main/body' => { 'html' => " <div id=\"id0\">\n </div>\n", 'bindings' => { 'id0' => ["lambda { |__p, __t, __c, __id| Volt::AttributeBinding.new(__p, __t, __c, __id, \"class\", Proc.new { main_class }, Proc.new { |val| self.main_class=(val) }) }"] } })
|
|
147
136
|
end
|
|
148
137
|
|
|
149
|
-
it
|
|
138
|
+
it 'should parse multiple attribute bindings in a single attribute' do
|
|
150
139
|
html = <<-END
|
|
151
140
|
<div class="start {{ main_class }} {{ awesome_class }} string">
|
|
152
141
|
</div>
|
|
153
142
|
END
|
|
154
143
|
|
|
155
|
-
view = Volt::ViewParser.new(html,
|
|
156
|
-
|
|
157
|
-
expect(view.templates).to eq({
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
})
|
|
144
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
145
|
+
|
|
146
|
+
expect(view.templates).to eq('main/main/main/body/_rv1' => {
|
|
147
|
+
'html' => 'start <!-- $0 --><!-- $/0 --> <!-- $1 --><!-- $/1 --> string',
|
|
148
|
+
'bindings' => {
|
|
149
|
+
0 => [
|
|
150
|
+
'lambda { |__p, __t, __c, __id| Volt::ContentBinding.new(__p, __t, __c, __id, Proc.new { main_class }) }'
|
|
151
|
+
],
|
|
152
|
+
1 => [
|
|
153
|
+
'lambda { |__p, __t, __c, __id| Volt::ContentBinding.new(__p, __t, __c, __id, Proc.new { awesome_class }) }'
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
'main/main/main/body' => {
|
|
158
|
+
'html' => " <div id=\"id0\">\n </div>\n",
|
|
159
|
+
'bindings' => {
|
|
160
|
+
'id0' => [
|
|
161
|
+
"lambda { |__p, __t, __c, __id| Volt::AttributeBinding.new(__p, __t, __c, __id, \"class\", Proc.new { Volt::StringTemplateRender.new(__p, __c, \"main/main/main/body/_rv1\") }) }"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
})
|
|
178
165
|
end
|
|
179
166
|
|
|
180
|
-
it
|
|
167
|
+
it 'should parse a template' do
|
|
181
168
|
html = <<-END
|
|
182
169
|
{{ template "/home/temp/path" }}
|
|
183
170
|
END
|
|
184
171
|
|
|
185
|
-
view = Volt::ViewParser.new(html,
|
|
186
|
-
|
|
187
|
-
expect(view.templates).to eq({
|
|
188
|
-
"main/main/main/body" => {
|
|
189
|
-
"html" => " <!-- $0 --><!-- $/0 -->\n",
|
|
190
|
-
"bindings" => {
|
|
191
|
-
0 => [
|
|
192
|
-
"lambda { |__p, __t, __c, __id| Volt::TemplateBinding.new(__p, __t, __c, __id, \"main/main/main/body\", Proc.new { [\"/home/temp/path\"] }) }"
|
|
193
|
-
]
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
end
|
|
172
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
198
173
|
|
|
174
|
+
expect(view.templates).to eq('main/main/main/body' => {
|
|
175
|
+
'html' => " <!-- $0 --><!-- $/0 -->\n",
|
|
176
|
+
'bindings' => {
|
|
177
|
+
0 => [
|
|
178
|
+
"lambda { |__p, __t, __c, __id| Volt::TemplateBinding.new(__p, __t, __c, __id, \"main/main/main/body\", Proc.new { [\"/home/temp/path\"] }) }"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
end
|
|
199
183
|
|
|
200
|
-
it
|
|
184
|
+
it 'should setup a href multiple attribute binding correctly' do
|
|
201
185
|
html = <<-END
|
|
202
186
|
<a href="/{link_name}">Link</a>
|
|
203
187
|
END
|
|
204
188
|
|
|
205
|
-
view = Volt::ViewParser.new(html,
|
|
189
|
+
view = Volt::ViewParser.new(html, 'main/main/main/body')
|
|
206
190
|
|
|
207
191
|
# puts view.templates.inspect
|
|
208
192
|
end
|
|
209
|
-
it
|
|
193
|
+
it 'should setup a href single attribute binding correctly' do
|
|
210
194
|
html = <<-END
|
|
211
195
|
<a href="{link_name}">Link</a>
|
|
212
196
|
END
|
|
213
197
|
|
|
214
|
-
view = Volt::ViewParser.new(html,
|
|
198
|
+
view = Volt::ViewParser.new(html, 'main/main/main/body')
|
|
215
199
|
|
|
216
200
|
# puts view.templates.inspect
|
|
217
201
|
end
|
|
218
202
|
|
|
219
|
-
it
|
|
203
|
+
it 'should parse components' do
|
|
220
204
|
|
|
221
205
|
end
|
|
222
206
|
|
|
223
|
-
it
|
|
207
|
+
it 'should parse sections' do
|
|
224
208
|
html = <<-END
|
|
225
209
|
<:Title>
|
|
226
210
|
This text goes in the title
|
|
@@ -229,42 +213,37 @@ describe Volt::ViewParser do
|
|
|
229
213
|
<p>This text goes in the body</p>
|
|
230
214
|
END
|
|
231
215
|
|
|
232
|
-
view = Volt::ViewParser.new(html,
|
|
233
|
-
|
|
234
|
-
expect(view.templates).to eq( {
|
|
235
|
-
"main/main/main/title" => {
|
|
236
|
-
"html" => "\n This text goes in the title\n\n "
|
|
237
|
-
},
|
|
238
|
-
"main/main/main/body" => {
|
|
239
|
-
"html" => "\n <p>This text goes in the body</p>\n"
|
|
240
|
-
}
|
|
241
|
-
})
|
|
216
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
242
217
|
|
|
218
|
+
expect(view.templates).to eq('main/main/main/title' => {
|
|
219
|
+
'html' => "\n This text goes in the title\n\n "
|
|
220
|
+
},
|
|
221
|
+
'main/main/main/body' => {
|
|
222
|
+
'html' => "\n <p>This text goes in the body</p>\n"
|
|
223
|
+
})
|
|
243
224
|
|
|
244
225
|
end
|
|
245
226
|
|
|
246
|
-
it
|
|
227
|
+
it 'should keep the html inside of a textarea if there are no bindings' do
|
|
247
228
|
html = <<-END
|
|
248
229
|
<textarea name="cool">some text in a textarea</textarea>
|
|
249
230
|
END
|
|
250
231
|
|
|
251
|
-
view = Volt::ViewParser.new(html,
|
|
232
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
252
233
|
|
|
253
|
-
expect(view.templates).to eq({
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
})
|
|
234
|
+
expect(view.templates).to eq('main/main/main/body' => {
|
|
235
|
+
'html' => " <textarea name=\"cool\">some text in a textarea</textarea>\n"
|
|
236
|
+
})
|
|
258
237
|
end
|
|
259
238
|
|
|
260
|
-
it
|
|
239
|
+
it 'should setup bindings for textarea values' do
|
|
261
240
|
html = <<-END
|
|
262
241
|
<textarea name="cool">{{ awesome }}</textarea>
|
|
263
242
|
END
|
|
264
243
|
|
|
265
|
-
view = Volt::ViewParser.new(html,
|
|
244
|
+
view = Volt::ViewParser.new(html, 'main/main/main')
|
|
266
245
|
|
|
267
|
-
expect(view.templates).to eq(
|
|
246
|
+
expect(view.templates).to eq('main/main/main/body' => { 'html' => " <textarea name=\"cool\" id=\"id1\"></textarea>\n", 'bindings' => { 'id1' => ["lambda { |__p, __t, __c, __id| Volt::AttributeBinding.new(__p, __t, __c, __id, \"value\", Proc.new { awesome }, Proc.new { |val| self.awesome=(val) }) }"] } })
|
|
268
247
|
end
|
|
269
248
|
end
|
|
270
249
|
|