# Weston: A new templating engine for CanJS apps

**URL:** https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468
**Category:** CanJS
**Created:** [November 11, 2016, 10:15pm UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468 "2016-11-11T22:15:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)
#### Post date: [November 11, 2016, 10:15pm UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468/1 "2016-11-11T22:15:45Z")

</div>

Hello everyone. A few months back I got the urge to try and do templating using the `<template>` element and fix some of the problems I find with Stache. Since CanJS 3.0 has opened up several APIs that stache uses, this turned out to be quite easy to do.

[weston](https://github.com/matthewp/weston) is my new project that provides an alternative templating engine based on the `<template>` tag. Please check out the readme to learn more, as it goes into greater detail on my motivations and explains some of the limitations it currently has.

CanJS 3.0 rocks because it makes creating your own templating engine **super** simple!

---

<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: [November 12, 2016, 9:00am UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468/2 "2016-11-12T09:00:57Z")

</div>

My thoughts…

1. Nice job, good to how easy it is to use canjs API.
2. Like that simple, “what you see is what you get” approach. That legacy concerns of the stache syntax should be removed in the future.

Dislikes:

- not another tamplate engine
- that “template” tag and the idea to put the partial on the Dom. The website will show the raw template and thats looks wired. Use SSR or a loading screen seems for me the better solutions,

---

<div class="post-metadata">

### Author: ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)
#### Post date: [November 14, 2016, 8:02pm UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468/3 "2016-11-14T20:02:34Z")

</div>

Thanks! To be clear, `<template>` and its children do not appear to the user. The browser treats its contents as inert. This means, for example, you can have images inside of a template and the browser won’t begin downloading them. And again, they aren’t visible in the page.

Two big advantages to use `<template>` over a string-based templating language like stache are:

- `<template>`s can be nested. You can have templates inside of templates. This is nice as a way to pass a template to a component. Script tags can’t be nested.
- You don’t need to do your own parsing with `<template>`, the browser’s HTML parses turns them into nodes for you. `template.content` is a DocumentFragment.

---

<div class="post-metadata">

### Author: ![janat08](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@janat08](https://forums.bitovi.com/u/janat08)
#### Post date: [June 8, 2018, 2:18pm UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468/4 "2018-06-08T14:18:09Z")

</div>

Can you fall back to mustach within template. I suppose you can with custom element.

---

<div class="post-metadata">

### Author: ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)
#### Post date: [June 8, 2018, 3:45pm UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468/5 "2018-06-08T15:45:41Z")

</div>

@janat08 What do you mean by mustache? Weston’s templates are mustache-like, but they are not the same as stache. You can use weston templates in some components and stache components in others. Note that weston hasn’t been upgraded to work with canjs@4, I’m not sure if I’ll ever do that (as I don’t use weston personally). If there were enough demand I might.

---

<div class="post-metadata">

### Author: ![janat08](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@janat08](https://forums.bitovi.com/u/janat08)
#### Post date: [June 8, 2018, 4:57pm UTC](https://forums.bitovi.com/t/weston-a-new-templating-engine-for-canjs-apps/468/6 "2018-06-08T16:57:37Z")

</div>

I asked that it get’s adopted in issue about making mustache like JS until JSX, [https://github.com/canjs/can-stache/issues/528](https://github.com/canjs/can-stache/issues/528).
