volt 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/volt/cli/asset_compile.rb +2 -2
- data/lib/volt/models/url.rb +2 -0
- data/lib/volt/page/bindings/template_binding.rb +42 -50
- data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +21 -0
- data/lib/volt/page/page.rb +3 -5
- data/lib/volt/server/rack/asset_files.rb +1 -1
- data/lib/volt/server/rack/component_html_renderer.rb +2 -2
- data/lib/volt/server/rack/index_files.rb +3 -3
- data/spec/apps/kitchen_sink/app/{home → main}/config/routes.rb +0 -0
- data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +3 -0
- data/spec/apps/kitchen_sink/app/{home/views/index/index.html → main/views/main/main.html} +0 -0
- data/spec/page/bindings/content_binding_spec.rb +2 -2
- data/spec/page/bindings/template_binding_spec.rb +31 -31
- data/spec/server/html_parser/view_parser_spec.rb +37 -37
- data/spec/server/rack/asset_files_spec.rb +1 -1
- data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
- data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +4 -0
- data/templates/newgem/app/newgem/views/{index/index.html → main/main.html} +0 -0
- data/templates/project/app/{home → main}/assets/css/.empty_directory +0 -0
- data/templates/project/app/{home → main}/assets/js/.empty_directory +0 -0
- data/templates/project/app/{home → main}/config/dependencies.rb +0 -0
- data/templates/project/app/{home → main}/config/routes.rb +0 -0
- data/templates/project/app/main/controllers/main_controller.rb +17 -0
- data/templates/project/app/{home → main}/models/.empty_directory +0 -0
- data/templates/project/app/{home/views/index → main/views/main}/about.html +0 -0
- data/templates/project/app/{home/views/index/home.html → main/views/main/index.html} +0 -0
- data/templates/project/app/main/views/main/main.html +29 -0
- metadata +19 -18
- data/spec/apps/kitchen_sink/app/home/controllers/index_controller.rb +0 -3
- data/templates/newgem/app/newgem/controllers/index_controller.rb.tt +0 -11
- data/templates/project/app/home/controllers/index_controller.rb +0 -9
- data/templates/project/app/home/views/index/index.html +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6c8120ac8ce1215c7a6f6b0b8df7c204096d62c
|
4
|
+
data.tar.gz: d02edaf4a739538d391a9258f33f71fbba3a8d67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ecb0bfc7ddd045d837ff0144b272d4791a6e60e3e15ff370cbfdcdb5a48f009823f4bdc0f0a53405dfe234b56d2acab41ff3fa2359c3ea79d80c51195d8216
|
7
|
+
data.tar.gz: beb777e469522b093ee1453145d9a4256ff661e4503639a2eb95bb835f714e67e02e267ca017ae0b1c7665732b023e64c80b1a2c06bb685fd4aa0e785c35896d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.6
|
@@ -36,14 +36,14 @@ class CLI
|
|
36
36
|
def write_component_js
|
37
37
|
component_paths = ComponentPaths.new(Volt.root)
|
38
38
|
|
39
|
-
code = ComponentCode.new('
|
39
|
+
code = ComponentCode.new('main', component_paths).code
|
40
40
|
|
41
41
|
javascript_code = Opal.compile(code)
|
42
42
|
|
43
43
|
components_folder = File.join(Volt.root, '/public/components')
|
44
44
|
puts "CF: #{components_folder}"
|
45
45
|
FileUtils.mkdir_p(components_folder)
|
46
|
-
File.open(File.join(components_folder, '/
|
46
|
+
File.open(File.join(components_folder, '/main.js'), 'w') do |file|
|
47
47
|
file.write(javascript_code)
|
48
48
|
end
|
49
49
|
end
|
data/lib/volt/models/url.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'volt/page/bindings/base_binding'
|
2
2
|
require 'volt/page/template_renderer'
|
3
|
+
require 'volt/page/bindings/template_binding/grouped_controllers'
|
3
4
|
|
4
5
|
class TemplateBinding < BaseBinding
|
5
6
|
def initialize(page, target, context, binding_name, binding_in_path, getter)
|
@@ -22,6 +23,12 @@ class TemplateBinding < BaseBinding
|
|
22
23
|
@arguments = section
|
23
24
|
end
|
24
25
|
|
26
|
+
# Sometimes we want multiple template bindings to share the same controller (usually
|
27
|
+
# when displaying a :Title and a :Body), this instance tracks those.
|
28
|
+
if @options && (controller_group = @options[:controller_group])
|
29
|
+
@grouped_controller = GroupedControllers.new(controller_group)
|
30
|
+
end
|
31
|
+
|
25
32
|
# Run the initial render
|
26
33
|
update
|
27
34
|
|
@@ -58,15 +65,15 @@ class TemplateBinding < BaseBinding
|
|
58
65
|
# until a file is either found or the component level is reached.
|
59
66
|
#
|
60
67
|
# The defaults are as follows:
|
61
|
-
# 1. component -
|
62
|
-
# 2. controller -
|
63
|
-
# 3. view -
|
68
|
+
# 1. component - main
|
69
|
+
# 2. controller - main
|
70
|
+
# 3. view - main
|
64
71
|
# 4. section - body
|
65
72
|
def path_for_template(lookup_path, force_section=nil)
|
66
73
|
parts = lookup_path.split('/')
|
67
74
|
parts_size = parts.size
|
68
75
|
|
69
|
-
default_parts = ['
|
76
|
+
default_parts = ['main', 'main', 'index', 'body']
|
70
77
|
|
71
78
|
# When forcing a sub template, we can default the sub template section
|
72
79
|
default_parts[-1] = force_section if force_section
|
@@ -106,6 +113,14 @@ class TemplateBinding < BaseBinding
|
|
106
113
|
return nil, nil
|
107
114
|
end
|
108
115
|
|
116
|
+
# Called when the path changes. If we are sharing a controller, clear the cached
|
117
|
+
# controller before we queue
|
118
|
+
def queue_update
|
119
|
+
@grouped_controller.clear if @grouped_controller
|
120
|
+
|
121
|
+
super
|
122
|
+
end
|
123
|
+
|
109
124
|
def update
|
110
125
|
full_path, controller_path = path_for_template(@path.cur, @section.cur)
|
111
126
|
# puts "UPDATE: #{@path.inspect} - #{full_path.inspect}"
|
@@ -128,61 +143,36 @@ class TemplateBinding < BaseBinding
|
|
128
143
|
def render_template(full_path, controller_path)
|
129
144
|
args = @arguments ? [@arguments] : []
|
130
145
|
|
131
|
-
|
132
|
-
# controllers. Maybe we should have a way to tie them together?
|
133
|
-
controller_class, action = get_controller(controller_path)
|
146
|
+
@controller = nil
|
134
147
|
|
135
|
-
if
|
136
|
-
|
137
|
-
current_context = controller_class.new(*args)
|
138
|
-
else
|
139
|
-
current_context = ModelController.new(*args)
|
140
|
-
end
|
141
|
-
@controller = current_context
|
148
|
+
# Fetch grouped controllers if we're grouping
|
149
|
+
@controller = @grouped_controller.get if @grouped_controller
|
142
150
|
|
143
|
-
#
|
144
|
-
|
151
|
+
# Otherwise, make a new controller
|
152
|
+
unless @controller
|
153
|
+
controller_class, action = get_controller(controller_path)
|
145
154
|
|
146
|
-
|
155
|
+
if controller_class
|
156
|
+
# Setup the controller
|
157
|
+
@controller = controller_class.new(*args)
|
158
|
+
else
|
159
|
+
@controller = ModelController.new(*args)
|
160
|
+
end
|
147
161
|
|
148
|
-
|
149
|
-
|
162
|
+
# Trigger the action
|
163
|
+
@controller.send(action) if @controller.respond_to?(action)
|
150
164
|
|
165
|
+
# Track the grouped controller
|
166
|
+
@grouped_controller.set(@controller) if @grouped_controller
|
167
|
+
end
|
151
168
|
|
169
|
+
@current_template = TemplateRenderer.new(@page, @target, @controller, @binding_name, full_path)
|
152
170
|
|
153
|
-
|
154
|
-
|
155
|
-
# # TODO: at the moment a :body section and a :title will both initialize different
|
156
|
-
# # controllers. Maybe we should have a way to tie them together?
|
157
|
-
# controller_class, action = get_controller(controller_path)
|
158
|
-
# if controller_class
|
159
|
-
# args = []
|
160
|
-
# puts "MODEL: #{@arguments.inspect}"
|
161
|
-
# args << SubContext.new(@arguments) if @arguments
|
162
|
-
#
|
163
|
-
# # Setup the controller
|
164
|
-
# current_context = controller_class.new(*args)
|
165
|
-
# @controller = current_context
|
166
|
-
#
|
167
|
-
# # Trigger the action
|
168
|
-
# @controller.send(action) if @controller.respond_to?(action)
|
169
|
-
# else
|
170
|
-
# # Pass the context directly
|
171
|
-
# current_context = @context
|
172
|
-
# @controller = nil
|
173
|
-
# end
|
174
|
-
#
|
175
|
-
# @current_template = TemplateRenderer.new(@page, @target, current_context, @binding_name, full_path)
|
176
|
-
#
|
177
|
-
# call_ready
|
178
|
-
# end
|
171
|
+
call_ready
|
172
|
+
end
|
179
173
|
|
180
174
|
def call_ready
|
181
175
|
if @controller
|
182
|
-
if @controller.respond_to?(:section=)
|
183
|
-
@controller.section = @current_template.section
|
184
|
-
end
|
185
|
-
|
186
176
|
if @controller.respond_to?(:dom_ready)
|
187
177
|
@controller.dom_ready
|
188
178
|
end
|
@@ -190,6 +180,8 @@ class TemplateBinding < BaseBinding
|
|
190
180
|
end
|
191
181
|
|
192
182
|
def remove
|
183
|
+
@grouped_controller.clear if @grouped_controller
|
184
|
+
|
193
185
|
if @path_changed_listener
|
194
186
|
@path_changed_listener.remove
|
195
187
|
@path_changed_listener = nil
|
@@ -230,7 +222,7 @@ class TemplateBinding < BaseBinding
|
|
230
222
|
parts = controller_path[0..-2].map {|v| v.gsub('-', '_').camelize }
|
231
223
|
|
232
224
|
# Home doesn't get namespaced
|
233
|
-
if parts.first == '
|
225
|
+
if parts.first == 'Main'
|
234
226
|
parts.shift
|
235
227
|
end
|
236
228
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Some template bindings share the controller with other template bindings based
|
2
|
+
# on a name. This class stores those and provides helper methods to clear/set/get.
|
3
|
+
class GroupedControllers
|
4
|
+
@@controllers = {}
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
@name = name
|
8
|
+
end
|
9
|
+
|
10
|
+
def get
|
11
|
+
@@controllers[@name]
|
12
|
+
end
|
13
|
+
|
14
|
+
def set(controller)
|
15
|
+
@@controllers[@name] = controller
|
16
|
+
end
|
17
|
+
|
18
|
+
def clear
|
19
|
+
@@controllers.delete(@name)
|
20
|
+
end
|
21
|
+
end
|
data/lib/volt/page/page.rb
CHANGED
@@ -43,8 +43,6 @@ class Page
|
|
43
43
|
attr_reader :url, :params, :page, :templates, :routes, :draw_cycle, :events
|
44
44
|
|
45
45
|
def initialize
|
46
|
-
# debugger
|
47
|
-
puts "------ Page Loaded -------"
|
48
46
|
@model_classes = {}
|
49
47
|
|
50
48
|
# Run the code to setup the page
|
@@ -163,10 +161,10 @@ class Page
|
|
163
161
|
# Do the initial url params parse
|
164
162
|
@url_tracker.url_updated(true)
|
165
163
|
|
166
|
-
main_controller =
|
164
|
+
main_controller = MainController.new
|
167
165
|
|
168
166
|
# Setup main page template
|
169
|
-
TemplateRenderer.new(self, DomTarget.new, main_controller, 'CONTENT', '
|
167
|
+
TemplateRenderer.new(self, DomTarget.new, main_controller, 'CONTENT', 'main/main/main/body')
|
170
168
|
|
171
169
|
# Setup title listener template
|
172
170
|
title_target = AttributeTarget.new
|
@@ -175,7 +173,7 @@ class Page
|
|
175
173
|
# puts "SET TITLE: #{title.inspect}: #{title_target.inspect}"
|
176
174
|
`document.title = title;`
|
177
175
|
end
|
178
|
-
TemplateRenderer.new(self, title_target, main_controller, "main", "
|
176
|
+
TemplateRenderer.new(self, title_target, main_controller, "main", "main/main/main/title")
|
179
177
|
|
180
178
|
# TODO: this dom ready should really happen in the template renderer
|
181
179
|
main_controller.dom_ready if main_controller.respond_to?(:dom_ready)
|
@@ -10,7 +10,7 @@ class IndexFiles
|
|
10
10
|
|
11
11
|
@@router ||= Routes.new.define do
|
12
12
|
# Find the route file
|
13
|
-
home_path = component_paths.component_path('
|
13
|
+
home_path = component_paths.component_path('main')
|
14
14
|
route_file = File.read("#{home_path}/config/routes.rb")
|
15
15
|
eval(route_file)
|
16
16
|
end
|
@@ -41,11 +41,11 @@ class IndexFiles
|
|
41
41
|
|
42
42
|
def javascript_files
|
43
43
|
# TODO: Cache somehow, this is being loaded every time
|
44
|
-
AssetFiles.new('
|
44
|
+
AssetFiles.new('main', @component_paths).javascript_files(@opal_files)
|
45
45
|
end
|
46
46
|
|
47
47
|
def css_files
|
48
|
-
AssetFiles.new('
|
48
|
+
AssetFiles.new('main', @component_paths).css_files
|
49
49
|
end
|
50
50
|
|
51
51
|
|
File without changes
|
File without changes
|
@@ -19,7 +19,7 @@ describe ContentBinding do
|
|
19
19
|
binding = lambda {|page, target, context, id| ContentBinding.new(page, target, context, id, Proc.new { self[:name] }) }
|
20
20
|
|
21
21
|
templates = {
|
22
|
-
'
|
22
|
+
'main/main' => {
|
23
23
|
'html' => 'hello <!-- $1 --><!-- $/1 -->',
|
24
24
|
'bindings' => {1 => [binding]}
|
25
25
|
}
|
@@ -30,7 +30,7 @@ describe ContentBinding do
|
|
30
30
|
|
31
31
|
dom = AttributeTarget.new(0)
|
32
32
|
|
33
|
-
TemplateRenderer.new(page, dom, context, 'main', '
|
33
|
+
TemplateRenderer.new(page, dom, context, 'main', 'main/main')
|
34
34
|
|
35
35
|
expect(dom.to_html).to eq('hello jimmy')
|
36
36
|
end
|
@@ -16,7 +16,7 @@ describe TemplateBinding do
|
|
16
16
|
# TODO: We should decouple things so we don't need to allocate
|
17
17
|
@template_binding = TemplateBinding.allocate
|
18
18
|
@template_binding.instance_variable_set('@page', @page)
|
19
|
-
@template_binding.setup_path('
|
19
|
+
@template_binding.setup_path('main/main/main')
|
20
20
|
end
|
21
21
|
|
22
22
|
def set_template(templates)
|
@@ -29,33 +29,33 @@ describe TemplateBinding do
|
|
29
29
|
|
30
30
|
it "should lookup nested controller action" do
|
31
31
|
@templates = {
|
32
|
-
'
|
33
|
-
'
|
32
|
+
'main/main/blog/nav' => '',
|
33
|
+
'main/comments/new/body' => '',
|
34
34
|
}
|
35
35
|
|
36
36
|
result = @template_binding.path_for_template('comments/new').last
|
37
|
-
expect(result).to eq(['
|
37
|
+
expect(result).to eq(['main', 'comments_controller', 'new'])
|
38
38
|
end
|
39
39
|
|
40
40
|
it "it should not look in the local component/controller for a specified controller/action" do
|
41
41
|
@templates = {
|
42
|
-
'
|
42
|
+
'main/comments/new/body' => ''
|
43
43
|
}
|
44
44
|
|
45
45
|
path, result = @template_binding.path_for_template('comments/new')
|
46
|
-
expect(path).to eq('
|
47
|
-
expect(result).to eq(['
|
46
|
+
expect(path).to eq('main/comments/new/body')
|
47
|
+
expect(result).to eq(['main', 'comments_controller', 'new'])
|
48
48
|
end
|
49
49
|
|
50
50
|
|
51
51
|
it "should handle a tripple lookup" do
|
52
52
|
@templates = {
|
53
|
-
'
|
53
|
+
'main/comments/new/errors' => '',
|
54
54
|
'comments/new/errors/body' => ''
|
55
55
|
}
|
56
56
|
|
57
57
|
path, result = @template_binding.path_for_template('comments/new/errors')
|
58
|
-
expect(path).to eq('
|
58
|
+
expect(path).to eq('main/comments/new/errors')
|
59
59
|
expect(result).to eq(nil)
|
60
60
|
end
|
61
61
|
|
@@ -72,75 +72,75 @@ describe TemplateBinding do
|
|
72
72
|
|
73
73
|
it "should find a matching component" do
|
74
74
|
@templates = {
|
75
|
-
'comments/new/
|
75
|
+
'comments/new/main/body' => ''
|
76
76
|
}
|
77
77
|
|
78
78
|
path, result = @template_binding.path_for_template('comments/new')
|
79
|
-
expect(path).to eq('comments/new/
|
80
|
-
expect(result).to eq(['comments', 'new_controller', '
|
79
|
+
expect(path).to eq('comments/new/main/body')
|
80
|
+
expect(result).to eq(['comments', 'new_controller', 'main'])
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should lookup sub-templates within its own file" do
|
84
84
|
@templates = {
|
85
|
-
'
|
86
|
-
'
|
85
|
+
'main/main/blog/nav' => '',
|
86
|
+
'main/main/main/nav' => '',
|
87
87
|
}
|
88
88
|
|
89
|
-
expect(@template_binding.path_for_template('nav').first).to eq('
|
89
|
+
expect(@template_binding.path_for_template('nav').first).to eq('main/main/main/nav')
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should lookup sub-templates within another local view" do
|
93
93
|
@templates = {
|
94
|
-
'
|
95
|
-
'
|
94
|
+
'main/main/blog/nav' => '',
|
95
|
+
'main/main/main/nav' => '',
|
96
96
|
}
|
97
97
|
|
98
|
-
expect(@template_binding.path_for_template('blog/nav').first).to eq('
|
98
|
+
expect(@template_binding.path_for_template('blog/nav').first).to eq('main/main/blog/nav')
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should lookup in another view" do
|
102
102
|
@templates = {
|
103
|
-
'
|
103
|
+
'main/main/nav/body' => '',
|
104
104
|
}
|
105
105
|
|
106
|
-
expect(@template_binding.path_for_template('nav').first).to eq('
|
106
|
+
expect(@template_binding.path_for_template('nav').first).to eq('main/main/nav/body')
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should lookup in a controller" do
|
110
110
|
@templates = {
|
111
|
-
'
|
111
|
+
'main/nav/main/body' => ''
|
112
112
|
}
|
113
113
|
|
114
|
-
expect(@template_binding.path_for_template('nav').first).to eq('
|
114
|
+
expect(@template_binding.path_for_template('nav').first).to eq('main/nav/main/body')
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should lookup in a controller/view" do
|
118
118
|
@templates = {
|
119
|
-
'
|
119
|
+
'main/blog/nav/body' => ''
|
120
120
|
}
|
121
121
|
|
122
|
-
expect(@template_binding.path_for_template('blog/nav').first).to eq('
|
122
|
+
expect(@template_binding.path_for_template('blog/nav').first).to eq('main/blog/nav/body')
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should lookup in a controller" do
|
126
126
|
@templates = {
|
127
|
-
'
|
127
|
+
'main/nav/main/body' => ''
|
128
128
|
}
|
129
129
|
|
130
|
-
expect(@template_binding.path_for_template('nav').first).to eq('
|
130
|
+
expect(@template_binding.path_for_template('nav').first).to eq('main/nav/main/body')
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should lookup in a component" do
|
134
134
|
@templates = {
|
135
|
-
'nav/
|
135
|
+
'nav/main/main/body' => ''
|
136
136
|
}
|
137
137
|
|
138
|
-
expect(@template_binding.path_for_template('nav').first).to eq('nav/
|
138
|
+
expect(@template_binding.path_for_template('nav').first).to eq('nav/main/main/body')
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should lookup in a component/controller/view" do
|
142
142
|
@templates = {
|
143
|
-
'nav/
|
143
|
+
'nav/main/main/body' => '',
|
144
144
|
'auth/login/new/body' => ''
|
145
145
|
}
|
146
146
|
|
@@ -149,10 +149,10 @@ describe TemplateBinding do
|
|
149
149
|
|
150
150
|
it "should let you force a sub template" do
|
151
151
|
@templates = {
|
152
|
-
'nav/
|
152
|
+
'nav/main/main/title' => '',
|
153
153
|
'auth/login/new/title' => ''
|
154
154
|
}
|
155
155
|
|
156
|
-
expect(@template_binding.path_for_template('nav', 'title').first).to eq('nav/
|
156
|
+
expect(@template_binding.path_for_template('nav', 'title').first).to eq('nav/main/main/title')
|
157
157
|
end
|
158
158
|
end
|
@@ -7,10 +7,10 @@ describe ViewParser do
|
|
7
7
|
it "should parse content bindings" do
|
8
8
|
html = "<p>Some {content} binding, {name}</p>"
|
9
9
|
|
10
|
-
view = ViewParser.new(html, "
|
10
|
+
view = ViewParser.new(html, "main/main/main")
|
11
11
|
|
12
12
|
expect(view.templates).to eq({
|
13
|
-
'
|
13
|
+
'main/main/main/body' => {
|
14
14
|
'html' => '<p>Some <!-- $0 --><!-- $/0 --> binding, <!-- $1 --><!-- $/1 --></p>',
|
15
15
|
'bindings' => {
|
16
16
|
0 => ["lambda { |__p, __t, __c, __id| ContentBinding.new(__p, __t, __c, __id, Proc.new { content }) }"],
|
@@ -34,23 +34,23 @@ describe ViewParser do
|
|
34
34
|
</p>
|
35
35
|
END
|
36
36
|
|
37
|
-
view = ViewParser.new(html, "
|
37
|
+
view = ViewParser.new(html, "main/main/main")
|
38
38
|
|
39
39
|
expect(view.templates).to eq( {
|
40
|
-
"
|
40
|
+
"main/main/main/body/__ifg0/__if0" => {
|
41
41
|
"html" => "\n text\n "
|
42
42
|
},
|
43
|
-
"
|
43
|
+
"main/main/main/body/__ifg0/__if1" => {
|
44
44
|
"html" => "\n <button>Button</button>\n "
|
45
45
|
},
|
46
|
-
"
|
46
|
+
"main/main/main/body/__ifg0/__if2" => {
|
47
47
|
"html" => "\n <a href=\"\">link</a>\n "
|
48
48
|
},
|
49
|
-
"
|
49
|
+
"main/main/main/body" => {
|
50
50
|
"html" => " <p>\n Some\n <!-- $0 --><!-- $/0 -->\n </p>\n",
|
51
51
|
"bindings" => {
|
52
52
|
0 => [
|
53
|
-
"lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"
|
53
|
+
"lambda { |__p, __t, __c, __id| 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\"]]) }"
|
54
54
|
]
|
55
55
|
}
|
56
56
|
}
|
@@ -73,28 +73,28 @@ describe ViewParser do
|
|
73
73
|
</p>
|
74
74
|
END
|
75
75
|
|
76
|
-
view = ViewParser.new(html, "
|
76
|
+
view = ViewParser.new(html, "main/main/main")
|
77
77
|
|
78
78
|
expect(view.templates).to eq( {
|
79
|
-
"
|
79
|
+
"main/main/main/body/__ifg0/__if0/__ifg0/__if0" => {
|
80
80
|
"html"=>"\n sub item text\n "
|
81
81
|
},
|
82
|
-
"
|
82
|
+
"main/main/main/body/__ifg0/__if0" => {
|
83
83
|
"html" => "\n <!-- $0 --><!-- $/0 -->\n ",
|
84
84
|
"bindings" => {
|
85
85
|
0 => [
|
86
|
-
"lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { sub_item }, \"
|
86
|
+
"lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { sub_item }, \"main/main/main/body/__ifg0/__if0/__ifg0/__if0\"]]) }"
|
87
87
|
]
|
88
88
|
}
|
89
89
|
},
|
90
|
-
"
|
90
|
+
"main/main/main/body/__ifg0/__if1" => {
|
91
91
|
"html" => "\n other\n "
|
92
92
|
},
|
93
|
-
"
|
93
|
+
"main/main/main/body" => {
|
94
94
|
"html" => " <p>\n Some\n <!-- $0 --><!-- $/0 -->\n </p>\n",
|
95
95
|
"bindings" => {
|
96
96
|
0 => [
|
97
|
-
"lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"
|
97
|
+
"lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"main/main/main/body/__ifg0/__if0\"], [nil, \"main/main/main/body/__ifg0/__if1\"]]) }"
|
98
98
|
]
|
99
99
|
}
|
100
100
|
}
|
@@ -111,10 +111,10 @@ describe ViewParser do
|
|
111
111
|
</div>
|
112
112
|
END
|
113
113
|
|
114
|
-
view = ViewParser.new(html, "
|
114
|
+
view = ViewParser.new(html, "main/main/main")
|
115
115
|
|
116
116
|
expect(view.templates).to eq({
|
117
|
-
"
|
117
|
+
"main/main/main/body/__template/0" => {
|
118
118
|
"html" => "\n <p><!-- $0 --><!-- $/0 --></p>\n ",
|
119
119
|
"bindings" => {
|
120
120
|
0 => [
|
@@ -122,11 +122,11 @@ describe ViewParser do
|
|
122
122
|
]
|
123
123
|
}
|
124
124
|
},
|
125
|
-
"
|
125
|
+
"main/main/main/body" => {
|
126
126
|
"html" => " <div class=\"main\">\n <!-- $0 --><!-- $/0 -->\n </div>\n",
|
127
127
|
"bindings" => {
|
128
128
|
0 => [
|
129
|
-
"lambda { |__p, __t, __c, __id| EachBinding.new(__p, __t, __c, __id, Proc.new { _items }, \"item\", \"
|
129
|
+
"lambda { |__p, __t, __c, __id| EachBinding.new(__p, __t, __c, __id, Proc.new { _items }, \"item\", \"main/main/main/body/__template/0\") }"
|
130
130
|
]
|
131
131
|
}
|
132
132
|
}
|
@@ -141,10 +141,10 @@ describe ViewParser do
|
|
141
141
|
</div>
|
142
142
|
END
|
143
143
|
|
144
|
-
view = ViewParser.new(html, "
|
144
|
+
view = ViewParser.new(html, "main/main/main")
|
145
145
|
|
146
146
|
expect(view.templates).to eq({
|
147
|
-
"
|
147
|
+
"main/main/main/body" => {
|
148
148
|
"html" => " <div id=\"id0\">\n </div>\n",
|
149
149
|
"bindings" => {
|
150
150
|
"id0" => [
|
@@ -161,10 +161,10 @@ describe ViewParser do
|
|
161
161
|
</div>
|
162
162
|
END
|
163
163
|
|
164
|
-
view = ViewParser.new(html, "
|
164
|
+
view = ViewParser.new(html, "main/main/main")
|
165
165
|
|
166
166
|
expect(view.templates).to eq({
|
167
|
-
"
|
167
|
+
"main/main/main/body/_rv1" => {
|
168
168
|
"html" => "start <!-- $0 --><!-- $/0 --> <!-- $1 --><!-- $/1 --> string",
|
169
169
|
"bindings" => {
|
170
170
|
0 => [
|
@@ -175,11 +175,11 @@ describe ViewParser do
|
|
175
175
|
]
|
176
176
|
}
|
177
177
|
},
|
178
|
-
"
|
178
|
+
"main/main/main/body" => {
|
179
179
|
"html" => " <div id=\"id0\">\n </div>\n",
|
180
180
|
"bindings" => {
|
181
181
|
"id0" => [
|
182
|
-
"lambda { |__p, __t, __c, __id| AttributeBinding.new(__p, __t, __c, __id, \"class\", Proc.new { ReactiveTemplate.new(__p, __c, \"
|
182
|
+
"lambda { |__p, __t, __c, __id| AttributeBinding.new(__p, __t, __c, __id, \"class\", Proc.new { ReactiveTemplate.new(__p, __c, \"main/main/main/body/_rv1\") }) }"
|
183
183
|
]
|
184
184
|
}
|
185
185
|
}
|
@@ -191,14 +191,14 @@ describe ViewParser do
|
|
191
191
|
{#template "/home/temp/path"}
|
192
192
|
END
|
193
193
|
|
194
|
-
view = ViewParser.new(html, "
|
194
|
+
view = ViewParser.new(html, "main/main/main")
|
195
195
|
|
196
196
|
expect(view.templates).to eq({
|
197
|
-
"
|
197
|
+
"main/main/main/body" => {
|
198
198
|
"html" => " <!-- $0 --><!-- $/0 -->\n",
|
199
199
|
"bindings" => {
|
200
200
|
0 => [
|
201
|
-
"lambda { |__p, __t, __c, __id| TemplateBinding.new(__p, __t, __c, __id, \"
|
201
|
+
"lambda { |__p, __t, __c, __id| TemplateBinding.new(__p, __t, __c, __id, \"main/main/main/body\", Proc.new { [\"/home/temp/path\"] }) }"
|
202
202
|
]
|
203
203
|
}
|
204
204
|
}
|
@@ -211,7 +211,7 @@ describe ViewParser do
|
|
211
211
|
<a href="/{link_name}">Link</a>
|
212
212
|
END
|
213
213
|
|
214
|
-
view = ViewParser.new(html, "
|
214
|
+
view = ViewParser.new(html, "main/main/main/body")
|
215
215
|
|
216
216
|
# puts view.templates.inspect
|
217
217
|
end
|
@@ -220,7 +220,7 @@ describe ViewParser do
|
|
220
220
|
<a href="{link_name}">Link</a>
|
221
221
|
END
|
222
222
|
|
223
|
-
view = ViewParser.new(html, "
|
223
|
+
view = ViewParser.new(html, "main/main/main/body")
|
224
224
|
|
225
225
|
# puts view.templates.inspect
|
226
226
|
end
|
@@ -238,13 +238,13 @@ describe ViewParser do
|
|
238
238
|
<p>This text goes in the body</p>
|
239
239
|
END
|
240
240
|
|
241
|
-
view = ViewParser.new(html, "
|
241
|
+
view = ViewParser.new(html, "main/main/main")
|
242
242
|
|
243
243
|
expect(view.templates).to eq( {
|
244
|
-
"
|
244
|
+
"main/main/main/title" => {
|
245
245
|
"html" => "\n This text goes in the title\n\n "
|
246
246
|
},
|
247
|
-
"
|
247
|
+
"main/main/main/body" => {
|
248
248
|
"html" => "\n <p>This text goes in the body</p>\n"
|
249
249
|
}
|
250
250
|
})
|
@@ -257,10 +257,10 @@ describe ViewParser do
|
|
257
257
|
<textarea name="cool">some text in a textarea</textarea>
|
258
258
|
END
|
259
259
|
|
260
|
-
view = ViewParser.new(html, "
|
260
|
+
view = ViewParser.new(html, "main/main/main")
|
261
261
|
|
262
262
|
expect(view.templates).to eq({
|
263
|
-
"
|
263
|
+
"main/main/main/body" => {
|
264
264
|
"html" => " <textarea name=\"cool\">some text in a textarea</textarea>\n"
|
265
265
|
}
|
266
266
|
})
|
@@ -271,10 +271,10 @@ describe ViewParser do
|
|
271
271
|
<textarea name="cool">{awesome}</textarea>
|
272
272
|
END
|
273
273
|
|
274
|
-
view = ViewParser.new(html, "
|
274
|
+
view = ViewParser.new(html, "main/main/main")
|
275
275
|
|
276
276
|
expect(view.templates).to eq({
|
277
|
-
"
|
277
|
+
"main/main/main/body" => {
|
278
278
|
"html" => " <textarea name=\"cool\" id=\"id1\"></textarea>\n",
|
279
279
|
"bindings" => {
|
280
280
|
"id1" => [
|
@@ -19,7 +19,7 @@ if RUBY_PLATFORM != 'opal'
|
|
19
19
|
it "should list all JS files" do
|
20
20
|
main = AssetFiles.new("main", @component_paths)
|
21
21
|
|
22
|
-
expect(main.javascript_files(nil)).to eq(["/assets/js/jquery-2.0.3.js", "/assets/js/sockjs-0.3.4.min.js", "/assets/js/vertxbus.js", "/assets/js/bootstrap.js", "/assets/js/test2.js", "/assets/js/test3.js", "/assets/js/test1.js", "/assets/volt/page/page.js", "/components/
|
22
|
+
expect(main.javascript_files(nil)).to eq(["/assets/js/jquery-2.0.3.js", "/assets/js/sockjs-0.3.4.min.js", "/assets/js/vertxbus.js", "/assets/js/bootstrap.js", "/assets/js/test2.js", "/assets/js/test3.js", "/assets/js/test1.js", "/assets/volt/page/page.js", "/components/main.js"])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class MainController < ModelController
|
2
|
+
def index
|
3
|
+
# Add code for when the index view is loaded
|
4
|
+
end
|
5
|
+
|
6
|
+
def about
|
7
|
+
# Add code for when the about view is loaded
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
# the main template contains a #template binding that shows another
|
12
|
+
# template. This is the path to that template. It may change based
|
13
|
+
# on the params._controller and params._action values.
|
14
|
+
def main_path
|
15
|
+
params._controller.or('main') + "/" + params._action.or('index')
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<:Title>
|
2
|
+
{#template main_path, "title", {controller_group: 'main'}}
|
3
|
+
|
4
|
+
<:Body>
|
5
|
+
<div class="container">
|
6
|
+
<div class="header">
|
7
|
+
<ul class="nav nav-pills pull-right">
|
8
|
+
<:nav href="/" text="Home" />
|
9
|
+
<:nav href="/blog" text="Blog" />
|
10
|
+
<:nav href="/about" text="About" />
|
11
|
+
</ul>
|
12
|
+
<h3 class="text-muted">Project name</h3>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<:volt:notices />
|
16
|
+
|
17
|
+
{#template main_path, 'body', {controller_group: 'main'}}
|
18
|
+
|
19
|
+
<div class="footer">
|
20
|
+
<p>© Company 2014</p>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<:Nav>
|
26
|
+
<li class="{#if url.path.split('/')[1] == @href.split('/')[1]}active{/}">
|
27
|
+
<a href="{@href}">{@text}</a>
|
28
|
+
</li>
|
29
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
@@ -408,6 +408,7 @@ files:
|
|
408
408
|
- lib/volt/page/bindings/event_binding.rb
|
409
409
|
- lib/volt/page/bindings/if_binding.rb
|
410
410
|
- lib/volt/page/bindings/template_binding.rb
|
411
|
+
- lib/volt/page/bindings/template_binding/grouped_controllers.rb
|
411
412
|
- lib/volt/page/channel.rb
|
412
413
|
- lib/volt/page/channel_stub.rb
|
413
414
|
- lib/volt/page/document.rb
|
@@ -478,9 +479,9 @@ files:
|
|
478
479
|
- spec/apps/file_loading/app/slideshow/assets/js/test3.js
|
479
480
|
- spec/apps/kitchen_sink/.gitignore
|
480
481
|
- spec/apps/kitchen_sink/Gemfile
|
481
|
-
- spec/apps/kitchen_sink/app/
|
482
|
-
- spec/apps/kitchen_sink/app/
|
483
|
-
- spec/apps/kitchen_sink/app/
|
482
|
+
- spec/apps/kitchen_sink/app/main/config/routes.rb
|
483
|
+
- spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
|
484
|
+
- spec/apps/kitchen_sink/app/main/views/main/main.html
|
484
485
|
- spec/apps/kitchen_sink/config.ru
|
485
486
|
- spec/apps/kitchen_sink/public/index.html
|
486
487
|
- spec/extra_core/inflector_spec.rb
|
@@ -526,8 +527,8 @@ files:
|
|
526
527
|
- templates/newgem/app/newgem/assets/js/.empty_directory
|
527
528
|
- templates/newgem/app/newgem/config/dependencies.rb
|
528
529
|
- templates/newgem/app/newgem/config/routes.rb
|
529
|
-
- templates/newgem/app/newgem/controllers/
|
530
|
-
- templates/newgem/app/newgem/views/
|
530
|
+
- templates/newgem/app/newgem/controllers/main_controller.rb.tt
|
531
|
+
- templates/newgem/app/newgem/views/main/main.html
|
531
532
|
- templates/newgem/bin/newgem.tt
|
532
533
|
- templates/newgem/gitignore.tt
|
533
534
|
- templates/newgem/lib/newgem.rb.tt
|
@@ -542,15 +543,15 @@ files:
|
|
542
543
|
- templates/project/Gemfile.tt
|
543
544
|
- templates/project/README.md.tt
|
544
545
|
- templates/project/app/.empty_directory
|
545
|
-
- templates/project/app/
|
546
|
-
- templates/project/app/
|
547
|
-
- templates/project/app/
|
548
|
-
- templates/project/app/
|
549
|
-
- templates/project/app/
|
550
|
-
- templates/project/app/
|
551
|
-
- templates/project/app/
|
552
|
-
- templates/project/app/
|
553
|
-
- templates/project/app/
|
546
|
+
- templates/project/app/main/assets/css/.empty_directory
|
547
|
+
- templates/project/app/main/assets/js/.empty_directory
|
548
|
+
- templates/project/app/main/config/dependencies.rb
|
549
|
+
- templates/project/app/main/config/routes.rb
|
550
|
+
- templates/project/app/main/controllers/main_controller.rb
|
551
|
+
- templates/project/app/main/models/.empty_directory
|
552
|
+
- templates/project/app/main/views/main/about.html
|
553
|
+
- templates/project/app/main/views/main/index.html
|
554
|
+
- templates/project/app/main/views/main/main.html
|
554
555
|
- templates/project/config.ru
|
555
556
|
- templates/project/public/index.html
|
556
557
|
- templates/project/spec/spec_helper.rb
|
@@ -589,9 +590,9 @@ test_files:
|
|
589
590
|
- spec/apps/file_loading/app/slideshow/assets/js/test3.js
|
590
591
|
- spec/apps/kitchen_sink/.gitignore
|
591
592
|
- spec/apps/kitchen_sink/Gemfile
|
592
|
-
- spec/apps/kitchen_sink/app/
|
593
|
-
- spec/apps/kitchen_sink/app/
|
594
|
-
- spec/apps/kitchen_sink/app/
|
593
|
+
- spec/apps/kitchen_sink/app/main/config/routes.rb
|
594
|
+
- spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
|
595
|
+
- spec/apps/kitchen_sink/app/main/views/main/main.html
|
595
596
|
- spec/apps/kitchen_sink/config.ru
|
596
597
|
- spec/apps/kitchen_sink/public/index.html
|
597
598
|
- spec/extra_core/inflector_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<:Title>
|
2
|
-
{#template params._controller.or('index') + '/' + params._action.or('home'), "title"}
|
3
|
-
|
4
|
-
<:Body>
|
5
|
-
<div class="container">
|
6
|
-
<div class="header">
|
7
|
-
<ul class="nav nav-pills pull-right">
|
8
|
-
<:nav action="" text="Home" />
|
9
|
-
<:nav action="about" text="About" />
|
10
|
-
</ul>
|
11
|
-
<h3 class="text-muted">Project name</h3>
|
12
|
-
</div>
|
13
|
-
|
14
|
-
<:volt:notices />
|
15
|
-
|
16
|
-
{#template params._controller.or('index') + '/' + params._action.or('home')}
|
17
|
-
|
18
|
-
<div class="footer">
|
19
|
-
<p>© Company 2014</p>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
</div>
|
23
|
-
|
24
|
-
|
25
|
-
<:Nav>
|
26
|
-
<li class="{#if params._action.or('') == @action}active{/}">
|
27
|
-
<a href="/{@action}">{@text}</a>
|
28
|
-
</li>
|
29
|
-
|