Added docs for body-only-if

This commit is contained in:
Patrick Steele-Idem 2014-12-11 12:19:21 -07:00
parent 58e0ecd1cc
commit 88b000b5c4

View File

@ -55,6 +55,7 @@ Syntax highlighting available for [Atom](https://atom.io/) by installing the [la
- [invoke](#invoke) - [invoke](#invoke)
- [Structure Manipulation](#structure-manipulation) - [Structure Manipulation](#structure-manipulation)
- [attrs](#attrs) - [attrs](#attrs)
- [body-only-if](#body-only-if)
- [Comments](#comments) - [Comments](#comments)
- [Helpers](#helpers) - [Helpers](#helpers)
- [Custom Tags and Attributes](#custom-tags-and-attributes) - [Custom Tags and Attributes](#custom-tags-and-attributes)
@ -1019,6 +1020,30 @@ The output would then be the following:
</div> </div>
``` ```
### body-only-if
If you find that you have a wrapper element that is conditional, but whose body should always be rendered then you can use the `body-only-if` attribute to handle this use case. For example, to only render a wrapping `<a>` tag if there is a valid URL then you could do the following:
```html
<a href="${data.linkUrl}" body-only-if="!data.linkUrl">
Some body content
</a>
```
Given a value of `"http://localhost/"` for the `data.linkUrl` variable: , the output would be the following:
```html
<a href="http://localhost/">
Some body content
</a>
```
Given a value of `undefined` for the `data.linkUrl` variable: , the output would be the following:
```html
Some body content
```
## Comments ## Comments
Standard HTML comments can be used to add comments to your template. The HTML comments will not show up in the rendered HTML. Standard HTML comments can be used to add comments to your template. The HTML comments will not show up in the rendered HTML.