You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,9 @@ There are a number of variables that are set by default to these helpers and are
15
15
-`_collection` - when using a `collection` attribute, the `_collection` variable will be set to the instance of the Rendr collection.
16
16
-`_block` - when passing a block to the `view` or `partial` helper, the `_block` variable will be available. This `_block` variable will be the HTML passed in.
17
17
18
+
18
19
#### view
19
20
------
20
-
21
21
The view helper is used to insert a new Rendr view. This is done on the server-side by generating the html and inserting it inline. On the client-side it creates a placeholder, and then in Rendr it will call the `attach` function to create a view instance and insert the HTML. If you don't pass any attributes to the helper, it sets the context (or scope) of the helper to the same as the parents.
22
22
23
23
You can also pass a block into the helper and it will be available inside of the created view as `_block`. This is helpful when you want to have a chunk of HTML differ in a view, but have the majority of it stay the same.
@@ -35,9 +35,9 @@ Example:
35
35
{{/view}}
36
36
```
37
37
38
+
38
39
#### partial
39
40
------
40
-
41
41
A partial is HTML only, and it is inserted at compile time of the templates, making them more performant than a view. These are good to use in cases where you don't have any view interaction and just want to reduce the amount of copied HTML. This will inherit the parents context if no attributes are passed into the helper.
42
42
43
43
Again, you can pass a block into the partial and access the `_block` variable inside of the partial. This is helpful when you want to set a variable chunk of HTML inside of a partial
@@ -55,9 +55,9 @@ Example:
55
55
{{/partial}}
56
56
```
57
57
58
+
58
59
#### json
59
60
------
60
-
61
61
This helper simply takes an object and runs `JSON.stringify` on the object. You can also pass the [spacing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#space_argument) into the helper.
62
62
63
63
Example:
@@ -68,9 +68,9 @@ Example:
68
68
{{ json myObject " " }}
69
69
```
70
70
71
+
71
72
#### each
72
73
------
73
-
74
74
Iterates an array setting the context to the value of the array element. Works as you would expect the Handlebars [each](http://handlebarsjs.com/builtin_helpers.html#iteration) helper to work, but this adds Rendr specific options set in the context (`_app`, `_model`, `_collection`, `_block`)
75
75
76
76
Example:
@@ -82,9 +82,9 @@ Example:
82
82
</ul>
83
83
```
84
84
85
+
85
86
#### forEach
86
87
------
87
-
88
88
Another helper to iterate items in the template, this has a bit more included though. You can iterate objects, arrays, or Collections with this, setting the value and the key attributes in the scope.
0 commit comments