What is Blaze ? *Baby don't hurt me...*

Hi, I am currently writing my bachelor thesis about UI and Meteor. I want to make a summary about Blaze and templates, how it works and what components it uses. The best would be a schema about the components and how they interact between themselves. Thus, I need to get an overview how each element interacts. Even though I know how to program with Blaze/Templates/Spacebars, I have little idea about how exactly it happens.

First of all, where is Blaze ? If I got it right, in Meteor, Blaze is located in the package called “blaze-html-template”. Blaze-html-template is a :

meta-package that includes everything you need to compile and run Meteor templates with Spacebars and Blaze.

What is everything you need ?

According to which, blaze has three core elements :

1. Templating
Compiles Blaze Template files. So basically, it takes all head and body of HTML a HTML file and put them all together in highest parent HTML file (I guess, correct me if I am wrong).

Whenever the compiler find the following :

<template name="o">
//some code

It creates a Blaze Template which I guess is a javascript Object. (again, correct me if I am wrong). Or maybe is a JSON that gets parsed by javascript ?

2. Blaze
Ah, finaly we come closer :

Blaze is a powerful library for creating user interfaces by writing reactive HTML templates.

Details :

Blaze has two major parts:

  • A template compiler that compiles template files into JavaScriptcode that runs against the Blaze runtime library.

May I ask what this Blaze runtime library is ? Google does not help with that one.

Moreover, Blaze provides a compiler toolchain (think LLVM) that can be used to support arbitrary template syntaxes.

Ok, so I can build my own Spacebars with that, but for us it is not important.

  • A reactive DOM engine that builds and manages the DOM at runtime,
    invoked via templates or directly from the app, which features
    reactively updating regions, lists, and attributes; event
    delegation; and many callbacks and hooks to aid the app developer.

Ok, really broad explanation. Sadly there is not explained in details on how this engine works. The rest of the documentation is basically an advert, not a documentation.


  • blaze
  • blaze-tools
  • html-tools
  • htmljs
  • spacebars
  • spacebars-compiler

So Blaze is a library and a package at the same time ? Maybe just FYI :

A library is a set of modules which makes sense to be together and that can be used in a program or another library.

A package is a unit of distribution that can contain a library or an executable or both. It’s a way to share your code with the community.

3. Spacebars

Spacebars is a Meteor template language…

This part easily understood, spacebars is the language with the bars like {{ #something }} and is uses Tracker and some Mongo functions. I guess that spacebars is only the language, Blaze is the one parsing and calling spacebars with different arguments.

What the documentation does not tell :

  • How does Blaze work client side ?
  • How does Blaze set up the UI ?
  • How does Blaze read the files (the ordering might be important)
  • How does Blaze create a data context ? (This is Blaze right ? or is it spacebars ? )

If anybody could help me in this mess, I just want an overview of what is going on. Meteor is nice for beginners, but there is a point in which you are forced to have advanced knowledge of the matter. And for that Meteor is terrible. (or Blaze, once again, it is not really clear).

Edit :
Also, the reason I need to know Blaze is to compare it to React and maybe evaluate which are the positive and negative points of both frameworks.

Edit n°2 :
http://guide.meteor.com/blaze.html for more information about Blaze

1 Like

As with any other tech project out there, there comes a point when you can’t just rely on documentation to give you the information you need unfortunately. No matter how much people try, the docs always fall behind, miss important details, don’t cover enough, etc. There is one thing that can answer all of your questions however - the Blaze source. This sounds like a tongue in cheek answer (how does a car work - well, tear apart the engine!), but it isn’t - if you want a more advanced understanding of Blaze you really should check out the source. It really isn’t that bad to follow through and see what’s happening.


I’ll suggest you to read “Meteor in Action”.
It’s a very good book that deepens a lot through the Meteor’s functionalities, it’ll help you a lot imho :smile:

The link, if you’re interested: https://www.manning.com/books/meteor-in-action

1 Like

The source code is indeed very easy to read. I guess that answers my questions. I did not think to read the source code, I expected uncommented code :relieved:

So Blaze is a library and a package at the same time?

Yes, nothing stops libraries from being packages. After all, a package is just a piece of code that is packaged with a building tool so that it can be reused between many applications.

So as long as this packaged code is a library, it makes both package and library.

For example, Momentjs is a popular library to manage date and time in your applications. It comes in the form of source code, npm package, meteor package and many others. Being an NPM or Meteor package doesn’t stop it from being a library.

A six-pack of beer doesn’t stop to be a beer just because it’s a six-pack.