Skip to content

Commit

Permalink
Create abe-each.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Jun 12, 2017
1 parent 0b2167a commit 49d1777
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions docs/types/abe-each.md
@@ -1,52 +1,51 @@
# Abe block each
# Type _each_

> group elements
> Group elements.
###Basic example
## Basic example

```html
{{#each myblock}}
​ <div>
{{abe type='text' key='myblock.text' desc='text item of the block'}}
</div>
​ <img src="{{abe type='image' key='myblock.image' desc='image item of the block'}}" />

<button>
{{abe type='text' key='button' desc='this button label is not part of this each statement'}}
</button>
<div>
{{abe type='text' key='myblock.text' desc='text item of the block'}}
</div>
<img src="{{abe type='image' key='myblock.image' desc='image item of the block'}}" />
<button>
{{abe type='text' key='button' desc='this button label is not part of this each statement'}}
</button>
{{/each}}
```

*Result :*
*Result:*

![Each](../assets/abe-each.png)

We have now a block each myblock that can be repeated as many time as we want with the '+' icon
We have now a block each myblock that can be repeated as many time as we want with the '+' icon.

Notice that since the <button> doesn't have ```key='myblock.button'``` but instead ```key='button'``` it won't be part of the each statement
Notice that since the `<button>` doesn't have `key='myblock.button'` but instead `key='button'` it won't be part of the each statement.

When the input button will have some content, any item each from myblock will have the same text for the element button
When the input button will have some content, any item each from `myblock` will have the same text for the element button.

Use case :
Use case:

Each statement are usefull for exemple for Carousel, list of element with un unknow number of item etc ...
Each statement are usefull for exemple for Carousel, list of element with un unknow number of item, etc.


###Grouped element
## Grouped element

Sometime we want to have a group of element but not inside of each statement because this group won't be repeated.

To do that, just use the same syntaxe as each block element but without wrapping them inside {{#each}} ... {{/each}} tag
To do that, just use the same syntaxe as each block element but without wrapping them inside `{{#each}} ... {{/each}}` tag:

```html
<div>
{{abe type='text' key='myblock.text' groupdesc='description for my group' desc='text item of the block'}}
</div>
<img src="{{abe type='image' key='myblock.image' groupdesc='description for my group' desc='image item of the block'}}" />
<div>
{{abe type='text' key='myblock.text' groupdesc='description for my group' desc='text item of the block'}}
</div>
<img src="{{abe type='image' key='myblock.image' groupdesc='description for my group' desc='image item of the block'}}" />
```

Notice groupdesc attribut that is use to write a description for our single grouped element
Notice `groupdesc` attribut that is use to write a description for our single grouped element.

*Result :*
*Result:*

![SIngleEach](../assets/single-group.png)
![SIngleEach](../assets/single-group.png)

0 comments on commit 49d1777

Please sign in to comment.