Looking for Blaze like templates without Meteor


#1

I have been using Meteor for some smaller projects and totally loved the idea of tags and how easy it is to bind data through javascript. For me it was easier than using Angular and their $scopes or React and their templates inside javascript.

I’m trying to make simple application, but without including client javascript from meteor framework. Is there something simmilar to Blaze templates, written as separate library, ready to download and include as tag in any project?

Regards!


#2

Handlebars or mustache.


#3

Or Vue.js if you wan’t a little bit more power, but still keep it simple.

<div id="app">
  {{ message }}
</div>
new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue.js!'
  }
})

https://vuejs.org/guide


#4

Thank you guys for suggestions. Handlebars looks pretty much close to Blaze. @smeijer Yeah i tried vue and it’s easier to use than ang and react for me, but data could be set in a few different ways for component: through data, through computed values and some other ways and i wasn’t sure which one to use and when, but yeah i considered it too.


#5

That’s because Blaze (Spacebars) is a fork of Handlebars.

If you just need a template engine, go with Handlebars. If you need more, like click-handlers (Blaze.helpers and Blaze.events) than you should go with Vue.js.

You use the simple data, if you need 1 way binding (render value x in your template). Computed values are if you need something like a fullname (fullname = firstname + lastname). And you have two-way binding. If you want to update value x when someone changes value y in an input somewhere on your page.

You can start small, use the data part as you would do with handlebars, the rest you can start using as your app evolves over time.


#6

I think i will give Vue a second try :wink:

Btw. as i can see, handlebars has some differences from blaze, for example in blaze you write:
<template name="aaa">...<template>

while in handlebars you write:
<script id="aaa" type="text/x-handlebars-template">...</script>


#7

expressjs with handlebars


#8

Just use Blaze… as a jQuery plugin: https://www.npmjs.com/package/jquery-meteor-blaze