# How to import a recursive stache template

**URL:** https://forums.bitovi.com/t/how-to-import-a-recursive-stache-template/289
**Category:** StealJS
**Created:** [May 27, 2016, 1:32pm UTC](https://forums.bitovi.com/t/how-to-import-a-recursive-stache-template/289 "2016-05-27T13:32:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)
#### Post date: [May 27, 2016, 1:32pm UTC](https://forums.bitovi.com/t/how-to-import-a-recursive-stache-template/289/1 "2016-05-27T13:32:41Z")

</div>

(Don’t know it this is the right forum)  
When I try to import a stache template that has a recursive loop, I get an error.

**Uncaught Error: can.view: No template or empty template:recursive\_template.mustache**  
_Info: can/view/view.js: There is no template or an empty template at upload\_main\_tree\_views\_smscTree\_stache.mustache_

I import the template like this:

```auto
import recursive_template from './views/template.stache';

```

The template is used like this:

````auto
this.element.html(recursive_template({children: items}));
```

The template looks like this.
If there are children, it uses the same template again.

```
<ul>
	{{#each children}}
		<li>
			...
			{{#hasChildren}}
				{{>recursive_template}}
			{{/hasChildren}}
		</li>
	{{/each}}
</ul>
```

The documentation states that the {{>key}} can also be a function, right?
https://canjs.com/docs/can.stache.helpers.partial.html

Or, do I have to register the template somehow?
````

---

<div class="post-metadata">

### Author: ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)
#### Post date: [May 27, 2016, 1:45pm UTC](https://forums.bitovi.com/t/how-to-import-a-recursive-stache-template/289/2 "2016-05-27T13:45:25Z")

</div>

Does:

```auto
var frag = recursive_template(
  {children: items}, 
  {
    partials: {recursive_template: recursive_template}
  })
this.element.html(frag);

```

work?

---

<div class="post-metadata">

### Author: ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)
#### Post date: [May 30, 2016, 7:20am UTC](https://forums.bitovi.com/t/how-to-import-a-recursive-stache-template/289/3 "2016-05-30T07:20:11Z")

</div>

Thx, Justin. That works.
