As mentioned, I'm experimenting with Durandal's compose binding to display a tree like structure.
Here's a knockout way of achieving this. (Imagine a models ko observable collection with an item that has properties Id, Name, Children where Children is an instance of the object just described. )
<ul class="nav" data-bind="template: { name: 'models_template', foreach: models }"></ul>
<script type="text/html" id="categories_template">
<li class="category_header" data-bind="attr: { id: 'category_' + Id }">
<span data-bind="text: Name"></span>
<!-- ko if: HasChildren -->
<ul data-bind='template: { name: "categories_template", foreach: Children }'>
</ul>-->
<!-- /ko -->
</li>
</script>
I've working on a Durandal approach but so far only get the following error (obviously I need
JavaScript runtime error: /App/views/Array.html HTTP status
<th>Name</th><th>Model</th>
<tbody data-bind="foreach: models">
<td data-bind="text: Name"></td>
<td data-bind="compose: { model: Children }"></td>