# Component & stache file structure

**URL:** <https://forums.bitovi.com/t/component-stache-file-structure/539>\
**Category:** CanJS\
**Created:** [January 19, 2017, 4:54pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539 "2017-01-19T16:54:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauldjackson](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pauldjackson](https://forums.bitovi.com/u/pauldjackson)\
**Post date:** [January 19, 2017, 4:54pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/1 "2017-01-19T16:54:39Z")

</div>

When migrating from v2.3 to v3 and trying to keep a similar neat component-based folder and file structure (as per the old tutorial), how do we load data from the stache file? We previously used can.view to load the template file but with can.stache this isn’t supported? Maybe I’m missing something?

I’ve got a new separate component js file, is it best to include the stache template directly in the component view as per the below example as this doesn’t seem as neat as before.

```
Component({
  tag: "my-tabs",
view: stache("<ul>{{#panels}}<li>{{title}}</li> ...")
});

```

An alternative is the below method but where do we load the stache file in this instance so that it sits neatly with the component?

`stache.from("my-template");`

Thanks,  
Paul

---

<div class="post-metadata">

**Author:** ![phillipskevin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/phillipskevin/32/102_2.png) [@phillipskevin](https://forums.bitovi.com/u/phillipskevin)\
**Post date:** [January 19, 2017, 5:41pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/2 "2017-01-19T17:41:40Z")

</div>

If you are using StealJS to load your modules, you should use [steal-stache](http://canjs.com/doc/steal-stache.html) to load your templates.

---

<div class="post-metadata">

**Author:** ![pauldjackson](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pauldjackson](https://forums.bitovi.com/u/pauldjackson)\
**Post date:** [January 26, 2017, 2:08pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/3 "2017-01-26T14:08:11Z")

</div>

thanks @phillipskevin

We aren’t using steal and are loading Can from the CDN. Is there recommended way to load components in this scenario? I’ll investigate using StealJS and steal-stache though if that’s the way to go.

---

<div class="post-metadata">

**Author:** ![chasen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/chasen/32/402_2.png) [@chasen](https://forums.bitovi.com/u/chasen)\
**Post date:** [January 26, 2017, 7:20pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/4 "2017-01-26T19:20:51Z")

</div>

@phillipskevin can correct me on this, but I think the recommended way to load template files is through your module loader.

For StealJS, that’d be using `steal-stache`: [http://canjs.com/doc/steal-stache.html](http://canjs.com/doc/steal-stache.html)

For webpack, something like this: [https://github.com/chasenlehara/canjs-webpack-example/blob/master/main.js#L5](https://github.com/chasenlehara/canjs-webpack-example/blob/master/main.js#L5)

…etc.

@pauldjackson, are you using a module loader for your files, or just `<script>` tags?

---

<div class="post-metadata">

**Author:** ![pauldjackson](https://avatars.discourse-cdn.com/v4/letter/p/e36b37/32.png) [@pauldjackson](https://forums.bitovi.com/u/pauldjackson)\
**Post date:** [January 27, 2017, 2:42pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/5 "2017-01-27T14:42:02Z")

</div>

Thanks @chasen. Sorry I should have mentioned that, we’re just using `<script>` tags.

---

<div class="post-metadata">

**Author:** ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)\
**Post date:** [January 29, 2017, 12:16pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/6 "2017-01-29T12:16:03Z")

</div>

You can simply use the `fetch` API [https://developer.mozilla.org/en-US/docs/Web/API/Fetch\_API/Using\_Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) to get the stache template raw data

---

<div class="post-metadata">

**Author:** ![chasen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/chasen/32/402_2.png) [@chasen](https://forums.bitovi.com/u/chasen)\
**Post date:** [January 30, 2017, 4:20pm UTC](https://forums.bitovi.com/t/component-stache-file-structure/539/7 "2017-01-30T16:20:29Z")

</div>

We should have better documentation on this. I created an issue for improving the migration guide: [https://github.com/canjs/canjs/issues/2991](https://github.com/canjs/canjs/issues/2991)

If someone has the time to pick it up, please just assign it to yourself, otherwise I’ll try to get to it this week.
