Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlebars helper - join #2710

Closed
tomakehurst opened this issue May 8, 2024 · 0 comments
Closed

Handlebars helper - join #2710

tomakehurst opened this issue May 8, 2024 · 0 comments
Assignees

Comments

@tomakehurst
Copy link
Member

Proposal

A very common use case when templating is to loop over some data and write out JSON array elements. Since these are comma-separated and can't have a trailing comma, this requires fairly verbose conditional code in order to create valid JSON.

A neater solution would be a join helper that could possibly be used on one of two ways:

{{join ',' myElements}}

or

{{#join ',' myData |as| item}}
{
  "id": "{{item.id}}",
  "name": "{{item.name}}
}
{{/join}}

References

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants