Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Meteor 0.8: Blaze Release Overhauls Rendering System

Meteor 0.8: Blaze Release Overhauls Rendering System

This item in japanese

Meteor has released version 0.8, bringing an “an overhaul of Meteor's rendering system.”

Meteor’s next generation live templating engine, Blaze, includes support for fine-grained DOM updates, jQuery integration and simpler API. Blaze replaces the live page update engine Spark that was introduced in version 0.4 in 2012.

On the Meteor blog Matt Debergalis describes Blaze as “developer-friendly” and that its architecture improves on Spark in “several ways.”

Blaze comes in two parts; the first part is a build-time compiler that transforms templates into JavaScript code. Spacebars -- the Handlebars-style compiler -- turns HTML templates into live updating DOM elements, allowing users to write normal looking HTML templates and helpers.

“When a user changes data or new data arrives over the network that a template depends on, Blaze updates your screen automatically,” without the need to “declare any dependencies or write code to manage how the screen updates,” Debergalis said.

The second part of Blaze is the runtime API that “renders elements, keeps track of their dependencies, and updates them through their complete lifecycle as those dependencies change”.

Among the replacements for advanced Spark APIs are the removal of Meteor.render, and a new pattern for defining custom block helpers. The list of added and deprecated APIs include the UI.body is now a template corresponding to the entire BODY element.

The Spacebars parser allows users to do several things that were “previously impossible”, such as:

  • HTML-aware updates. The template parser now parses HTML tags in addition to stache tags, making finer-grained reactive updates possible, including attribute-level updates to DOM elements.
  • Precompilation. The Spacebars compiler generates simple procedural code that calls an internal Meteor interface which in the future will perform either client-side or server-side rendering. This is more efficient than either interpreting the template or parsing its HTML output at runtime.
  • Syntax extensions. Handlebars syntax is extremely minimal, and we foresee adding some additional well-chosen extensions over time. (We will also implement the top features of current Handlebars that are missing from Meteor, like #each that supports objects and lets you access the current index or key.)

As of Meteor 0.8 the Handlebars namespace is deprecated. The Handlebars.SafeString is now Spacebars.SafeString, and Handlebars.registerHelper is now UI.registerHelper

Spacebars requires HTML to be “well-formed”. The Using Blaze github page notes: “In Spark, HTML parsing was done by the browser which is more lenient.”

In addition, the Blaze HTML parser doesn't currently fully implement the HTML spec. The release notes specify that it doesn't automatically close certain tags, such as <p> and <li>.

The 0.8 release was greeted by the Meteor community with enthusiasm. In the Meteor group on LinkedIn, user Uğur Toprakdeviren started a discussion, asking: “What is your opinion of new version of Meteor 0.8.0 (Blaze, Spacebars etc)”.

Aaron Singmaster-Judd, founder & CTO at Ongo Works, replied “awesome, well done, and kudos to the Meteor team and the community package developers work on the new codebase.

“[it] may require some effort to upgrade existing packages, and renders a fair amount of information out in the webs invalid, but worth the price of progress.”

On Hacker News, the update was also well received. User elsherbini commented on the jQuery integration “jquery compatibility is huge, awesome!”. Other users shared the positive sentiment about the Blaze release, including TylerE commenting on the compiler: “I have to say I'm pretty excited, since it now looks like there is a non-hacky way to use jade templates, which as far as I'm concerned are a big win.”

Debergalis notes that the live templating engine is the only new feature of the 0.8 release and is a major step towards the Meteor 1.0 release.

Rate this Article