volt 0.4.17 → 0.4.18
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/Readme.md +8 -4
- data/VERSION +1 -1
- data/templates/project/app/home/config/routes.rb +1 -1
- data/templates/project/app/home/views/index/index.html +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bd56992ff8ae73d3af5d43f4d4a73d528c4a249
|
4
|
+
data.tar.gz: eb337a2886b9625c09c90e9f5634bbf975f91768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07dc0de1053f83ca3325566dbe61b96f51ac2e14280dd6ef9a336de6afcff122c2544667c83ea31a3e24e10b4c8bb6936ba525f8d6cec990a274f0d44650c699
|
7
|
+
data.tar.gz: eff6fe08d0f836de3ebb822795a4704a88852c0eedcd2b42a21a96162e9adf3aa18eb1711124a800406e0bf20c2498accf72320c520920c66e2e0936c003424f
|
data/Readme.md
CHANGED
@@ -398,6 +398,8 @@ For convience, when placing a hash inside of another model, it is automatically
|
|
398
398
|
|
399
399
|
Models are accessed differently from hashes. Instead of using model[:symbol] to access, you call a method model.method_name. This provides a dynamic unified store where setters and getters can be added without changing any access code.
|
400
400
|
|
401
|
+
You can get a ruby hash back out by calling .to_h on a Model.
|
402
|
+
|
401
403
|
### Array -> ArrayModel
|
402
404
|
|
403
405
|
Arrays inside of models are automatically converted to an instance of ArrayModel. ArrayModels behave the same as a normal Array except that they can handle things like being bound to backend data and triggering reactive events.
|
@@ -431,6 +433,8 @@ To convert a Model or an ArrayModel back to a normal hash, call .to_h or .to_a r
|
|
431
433
|
items
|
432
434
|
```
|
433
435
|
|
436
|
+
You can get a normal array again by calling .to_a on an ArrayModel.
|
437
|
+
|
434
438
|
# Controllers
|
435
439
|
|
436
440
|
A controller can be any class in Volt, however it is common to have that class inherit from ModelController. A model controller lets you specify a model that the controller works off of. This is a common pattern in Volt. To assign the current model for a controller, simply call the model method passing in one of the following:
|
@@ -594,7 +598,7 @@ This means that routes in volt have to go both from url to params and params to
|
|
594
598
|
Routes are specified on a per-component basis in the config/routes.rb file. Routes simply map from url to params.
|
595
599
|
|
596
600
|
```ruby
|
597
|
-
get "/todos",
|
601
|
+
get "/todos", _view: 'todos'
|
598
602
|
```
|
599
603
|
|
600
604
|
Routes take two arguments, a path, and a params hash. When a new url is loaded and the path is matched on a route, the params will be set to the params provided for that route.
|
@@ -606,12 +610,12 @@ When the params are changed, the url will be set to the path for the route that'
|
|
606
610
|
Route path's can also contain variables similar to bindings.
|
607
611
|
|
608
612
|
```ruby
|
609
|
-
get "/todos/{_index}",
|
613
|
+
get "/todos/{_index}", _view: 'todos'
|
610
614
|
```
|
611
615
|
|
612
|
-
In the case above, if any url matches /todos/*, (where * is anything but a slash), it will be the active route. params.
|
616
|
+
In the case above, if any url matches /todos/*, (where * is anything but a slash), it will be the active route. params._view would be set to 'todos', and params._index would be set to the value in the path.
|
613
617
|
|
614
|
-
If params.
|
618
|
+
If params._view is 'todos' and params._index is not nil, the route would be matched.
|
615
619
|
|
616
620
|
Routes are matched top to bottom in a routes file.
|
617
621
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.18
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<:title>
|
2
|
-
{#template params.
|
2
|
+
{#template params._view.or('home'), "title"}
|
3
3
|
</:title>
|
4
4
|
|
5
5
|
<:body>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<h3 class="text-muted">Project name</h3>
|
15
15
|
</div>
|
16
16
|
|
17
|
-
{#template params.
|
17
|
+
{#template params._view.or('home')}
|
18
18
|
|
19
19
|
<div class="footer">
|
20
20
|
<p>© Company 2014</p>
|