Skip to content

Commit 680ed67

Browse files
Merge pull request Jasonette#40 from brad/root-docs
add some documentation about `$root`
2 parents b789329 + 33262c9 commit 680ed67

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/templates.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To achieve this we use templates.
88

99
1. Templates have slots (`{{ }}`) to be filled in.
1010
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`)**.
1212
4. Templates are always declared under `$jason.head.templates`.
1313
5. Most of the times we just use the `body` template (`$jason.head.templates.body`).
1414

@@ -289,7 +289,7 @@ Let's say we are are trying to render the following return value (`$jason`):
289289
}
290290
}
291291

292-
What happens when we run above data through the following template?
292+
What happens when we run above data through the following template?
293293

294294
{
295295
"type": "label",
@@ -370,6 +370,8 @@ This is where `this` comes in. To handle this situation we can write the followi
370370
}
371371
}
372372

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+
373375

374376
##Non-JSON
375377

@@ -382,7 +384,7 @@ To do this, use [$convert.csv](actions.md#convertcsv)
382384

383385
**[Here's a functional example](http://www.jasonbase.com/things/B1m/edit)**
384386

385-
---
387+
---
386388

387389
###RSS
388390
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)
391393

392394
**[Here's a functional example](http://www.jasonbase.com/things/2dL/edit)**
393395

394-
---
396+
---
395397

396398
###HTML
397399
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
652654
- etc.
653655

654656

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.
656658

657659
{
658660
"$jason": {

0 commit comments

Comments
 (0)