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: docs/templates.md
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ To achieve this we use templates.
8
8
9
9
1. Templates have slots (`{{ }}`) to be filled in.
10
10
2. All expressions inside `{{ }}` are evaluated with the data in memory and substituted in.
11
-
3. Templates handle not only evaluation but also support **looping (`#each`) and conditionals (`#if/#elseif/#else`)**.
11
+
3. Templates handle not only evaluation but also support **looping (`#each`) and conditionals (`#if/#elseif/#else`)**.
12
12
4. Templates are always declared under `$jason.head.templates`.
13
13
5. Most of the times we just use the `body` template (`$jason.head.templates.body`).
14
14
@@ -289,7 +289,7 @@ Let's say we are are trying to render the following return value (`$jason`):
289
289
}
290
290
}
291
291
292
-
What happens when we run above data through the following template?
292
+
What happens when we run above data through the following template?
293
293
294
294
{
295
295
"type": "label",
@@ -370,6 +370,8 @@ This is where `this` comes in. To handle this situation we can write the followi
370
370
}
371
371
}
372
372
373
+
Keep in mind that the change in context makes global objects such as `$get`, and `$cache` inaccessible. You can use the `$root` object to get at them, e.g. `$root.$get`.
374
+
373
375
374
376
##Non-JSON
375
377
@@ -382,7 +384,7 @@ To do this, use [$convert.csv](actions.md#convertcsv)
382
384
383
385
**[Here's a functional example](http://www.jasonbase.com/things/B1m/edit)**
384
386
385
-
---
387
+
---
386
388
387
389
###RSS
388
390
When you have an RSS content, you can parse it into JSON format before feeding it into a template.
@@ -391,7 +393,7 @@ To do this, use [$convert.rss](actions.md#convertrss)
391
393
392
394
**[Here's a functional example](http://www.jasonbase.com/things/2dL/edit)**
393
395
394
-
---
396
+
---
395
397
396
398
###HTML
397
399
Unlike other formats like CSV and RSS, Jasonette implements a separate HTML template engine, so we don't need to parse HTML into JSON.
@@ -652,7 +654,7 @@ You can render templates using any type of data, which includes **local variable
652
654
- etc.
653
655
654
656
655
-
**Example:** Below, we render the label using a local variable named `message`, which is automatically set whenever the `textfield` value changes. **Note that there is no top level `body` element after `head`.** Instead we have a `body` template, which will be rendered into body whenever we call the `$render` action.
657
+
**Example:** Below, we render the label using a local variable named `message`, which is automatically set whenever the `textfield` value changes. **Note that there is no top level `body` element after `head`.** Instead we have a `body` template, which will be rendered into body whenever we call the `$render` action.
0 commit comments