I’m trying to render a view in a template multiple times with different data each time, specifically like this:
<script type="text/x-handlebars" data-template-name="foobar">
{{render "_people" peopleArray}}
<!-- ... -->
{{render "_people" anotherPeopleArray}}
</script>
<script type="text/x-handlebars" data-template-name="_people">
{{#each person in controller}}
{{person.name}}
{{/each}}
</script>
I get the JS error: “assertion failed: This view is already rendered”.
If I change the {{render "_people"}} to {{partial "people"}} then it will render multiple times, but I do not know how to pass different data into there.
To clarify, I to be able to create a partial/view, which I can pass data to, and can call multiple times. I’m sure this is simple and I’m just missing something.
Any help would be appreciated. Thank you.
You can use
{{render}}only once. If you need to do it multiple times, use{{control}}instead, such as:{{control "people" peopleArray}}
This will create a
peopletemplate withPeopleViewandPeopleControllerwith it’scontentset topeopleArray