Jade templating in Meteor

We would love to see Jade integration. Use packages/handlebars as a template.

The basic strategy is to wire the output of the template engine into Meteor.ui.render which is how we implement live page updates. As long as your template returns HTML, that’ll work. Any time a Jade template references a Meteor.Collection document or Session variable, Meteor will register that dependency so that knows to rerender the template when the data changes.

Even better, though, is to also use Meteor.ui.chunk and Meteor.ui.listChunk. These will limit the amount of recalculation Meteor has to do when there’s a change. For example, if you are rendering a list of documents using {{#each}} in Handlebars-speak, there’s no reason to recalculate the whole template when a new document enters the result set. We just render one HTML chunk for the new document, and insert that right into the DOM. That’s listChunk in action.

So you’ll likely find that instrumenting just if/unless and for/each in Jade gets you a long way there.

Just be aware, package development is not as documented as the other parts of the system. So don’t hesitate to ask more specific questions as you go.

Leave a Comment