In your place, I would have done the following:
- Create a custom element (CE) that accepts a template string and a binding context or scope.
- That CE is responsible for the following:
- Parsing the template string to a DOM tree. Don’t worry about the Aurelia syntax for this part, and simply use the standard
DOMParser
. - Enhancing the DOM tree with the bound context, using the
templatingEngine.enhance
(if you are unaware of that, search for that in the docs). This step will hydrate the DOM tree with Aurelia magic. - Attach the enhanced DOM tree to the view, and you are done.
- Well almost. Make sure to clean up properly when this CE goes out of context (unbound, detached etc.). For that, you can refer this thread.
- Parsing the template string to a DOM tree. Don’t worry about the Aurelia syntax for this part, and simply use the standard
- Use the CE in your list and bind the template and the context as deemed fit.