Skip to content

Commit

Permalink
Add the prefix and suffix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
leeturner committed May 21, 2024
1 parent 01fcc2a commit aab7905
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions _docs/response-templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ You can also specify a `prefix` and `suffix` to be added to the start and end of

```handlebars
{{arrayJoin ',' (array 'One' 'Two' 'Three') prefix='[' suffix=']'}} // [One,Two,Three]
{{arrayJoin ' * ' (array 1 2 3) prefix='(' suffix=')'}} // (1 * 2 * 3)
```

{% endraw %}
Expand All @@ -807,6 +808,21 @@ The `arrayJoin` helper can also be used as a block helper:
"name{{item.id}}": "{{item.name}}"
}
{{/arrayJoin}}] // [{ "name1": "One" }, { "name2": "Two" }, { "name3": "Three" }]
// or the same example with the prefix and suffix parameters
{{#parseJson 'myThings'}}
[
{ "id": 1, "name": "One" },
{ "id": 2, "name": "Two" },
{ "id": 3, "name": "Three" }
]
{{/parseJson}}
{{#arrayJoin ',' myThings prefix='[' suffix=']' as |item|}}
{
"name{{item.id}}": "{{item.name}}"
}
{{/arrayJoin}} // [{ "name1": "One" }, { "name2": "Two" }, { "name3": "Three" }]
```

{% endraw %}
Expand Down

0 comments on commit aab7905

Please sign in to comment.