Permalink
Browse files

Include explicit truthiness section instead of a link

Fix broken link to Blocks guide

Closes #731
Closes #711
  • Loading branch information...
1 parent 49c90eb commit 8f2d42d8da2f7ccdcf6ced728d917bab71d96339 Seth Kinast committed Jun 3, 2016
Showing with 16 additions and 8 deletions.
  1. +2 −2 docs/template-api.md
  2. +14 −6 guides/getting-started.md
View
@@ -119,7 +119,7 @@ A not-exists section is a special type of section that outputs its contents if t
</dust-demo>
<h3 id="helper"><code>{@helper/}</code></h3>
-A helper is special kind of section that executes some JavaScript when it is rendered. For more information on using helpers, see the [Dust helpers guide](/guides/dust-helpers). For more information on writing Dust helpers, see the [writing helpers guide](/guides/writing-helpers).
+A helper is a special kind of section that executes some JavaScript when it is rendered. For more information on using helpers, see the [Dust helpers guide](/guides/dust-helpers). For more information on writing Dust helpers, see the [writing helpers guide](/guides/writing-helpers).
<dust-demo templatename="helper">
<dust-demo-template showtemplatename="true">The answer is {@eq key=answer value=42}42{:else}wrong{/eq}.</dust-demo-template>
@@ -137,7 +137,7 @@ An inline-partial is defined as a single opening curly brace `{`, follwed by a l
{<classNames}primary hero{/classNames}
```
-A self-closing block is defined as a single opening curly brace `{`, followed by a plus sign `+`, followed by the name used in the inline-partial, followed by a forward slash and single closing curly brace `/}`. Alternatively, a block can have content. A block's content is output only if a matching inline-partial is not found. For more info, see the [base and override templates guide](/guides/base-and-override-templates).
+A self-closing block is defined as a single opening curly brace `{`, followed by a plus sign `+`, followed by the name used in the inline-partial, followed by a forward slash and single closing curly brace `/}`. Alternatively, a block can have content. A block's content is output only if a matching inline-partial is not found. For more info, see the [base and override templates guide](/guides/blocks).
<dust-demo templatename="inline_partial">
<dust-demo-template showtemplatename="true">{+greeting}Hello!{/greeting} world.
View
@@ -37,26 +37,34 @@ If you need to reference values within nested objects, you can use dot-notation
Learn more about [Dust References](/docs/syntax#reference).
### Conditionals
-Dust can include content conditionally with `?` (exists) and `^` (not exists). Given a reference, the conditionals check if the value of that reference is truthy or falsy, then output the content accordingly. See the [conditionals syntax documentation](/docs/syntax#exists) for more information on what is truthy and what is falsy in Dust.
+Dust can include content conditionally with `?` (exists) and `^` (not exists). Given a reference, the conditionals check if the value of that reference is truthy or falsy, then output the content accordingly.
<dust-tutorial templatename="conditional">
-<dust-demo-template showtemplatename="true">&lt;input type="checkbox"{^isSelected} selected{/isSelected}&gt;</dust-demo-template>
+<dust-demo-template showtemplatename="true">&lt;input type="checkbox"{?isSelected} selected{/isSelected}&gt;
+{?friends} {friends.length} Friends!{/friends}
+{?enemies} Oh no, enemies!{/enemies}</dust-demo-template>
<dust-demo-json>{
- isSelected: true
+ isSelected: false,
+ friends: ["Alice", "Bob"],
+ enemies: ["Oscar"]
}</dust-demo-json>
-<dust-tutorial-answer>&lt;input type="checkbox" selected&gt;</dust-tutorial-answer>
+<dust-tutorial-answer>&lt;input type="checkbox" selected&gt; 2 Friends!</dust-tutorial-answer>
</dust-tutorial>
You can also use an `{:else}` statement with conditionals.
<dust-tutorial templatename="else">
-<dust-demo-template showtemplatename="true">&lt;li class="result{?isPrimary} primary{:else} {/isPrimary}"&gt;</dust-demo-template>
+<dust-demo-template showtemplatename="true">&lt;li class="result{?isPrimary} primary{:else} secondary{/isPrimary}"&gt;</dust-demo-template>
<dust-demo-json>{
- isPrimary: false
+ isPrimary: true
}</dust-demo-json>
<dust-tutorial-answer>&lt;li class="result secondary"&gt;</dust-tutorial-answer>
</dust-tutorial>
+#### Truthiness
+
+Dust uses a slightly different definition of truthiness than Javascript. The only non-truthy values for the purpose of conditional tests are `null`, `undefined`, and an empty Array. Values like the string "false", the number 0, and empty Objects are considered truthy. If you need test for these values, look at the [Dust `{@eq}` and `{@ne}` helpers](/guides/dust-helpers/#logic-helpers).
+
### Sections
Sections, which work a lot like conditionals, are a useful alternative to the sometimes verbose dot-notation. A section is used to switch the context in which Dust looks up references.

0 comments on commit 8f2d42d

Please sign in to comment.