BorisMoore/jsrender — Issue #54: render sub template tag is missing
Author: fredyang
Created: 2011-12-23 06:15:03+00:00
State: open

I know that I can use the following to render sub template,

{{each Languages tmpl="#columnTemplate"}}

However, what I want is

{{render Languages tmpl="#columnTemplate"}}

This is useful to render recursive template. For example, I have an data source call root, and the root.categories is an array of category, and category.categories is the category's sub categories.

Now I need to write, yes it works

<script type="text/html" id="page">

...other stuff
<ul>
{{each categories tmpl="menu"}}
</ul>
..other stuff
</script>

<script type="text/html" id="menu" >
<li><a href="#">{{=name!}}</a>
{{#if categories}}
<ul>
{{each categories tmpl="menu"}}
</ul>
{{/if}}
</li>
</script>

What I want to write is the following code

<script type="text/html" id="page" >
...other stuff
{{render $data tmpl="menu"}}
..other stuff
</script>

<script type="text/html" id="menu" >
{{#if categories}}
<ul>
{{#each categories}}
<li><a href="#">{{=name!}}</a>
{{render $data tmpl="menu"}}
</li>
{{/each}}
</ul>
{{/if}}
</script>

This is a subtle difference, but I don't need to write >ul< in the page template. Is it missing, or I don't need it?