Create Blaze containers without writing any markup


I just published a package called planefy:blaze-containers that allows you to create simple containers around your Blaze templates.

This was inspired by react-meteor-data and react-komposer. It’s really just an experiment at this point, but I’d be interested to know if people think this is useful, good pattern, etc.

Basically it works like this:

// ../client/container.js
// assume you already have a template called 'childTemplate' defined

import { createContainer } from 'meteor/planefy:blaze-container'

createContainer('containerTemplate', 'childTemplate', function() {
   const handle = Meteor.subscribe('posts');
   return {
       ready: handle.ready(),
       posts: Posts.find().fetch()

That’s it, that’s all you need to do.

This will define a template called ‘containerTemplate’. You don’t need to need add any HTML
for containerTemplate. That is handled for you.

Now you can use include containerTemplate in your router or in other templates. It will pass the new data to childTemplate
reactively, whenever one of the dependencies is updated.

It will also pass through any data provided to containerTemplate, so that if you had another template that looked like this:

<template name="superContainer">
  {{> containerTemplate user=user}}

Then childTemplate will receive both user , ready, and posts as its data context. In other words, it will be just like
you did this:

<template name="other">
 {{> childTemplate user=user posts=posts ready=ready }}


Version 1.0 has been published with test coverage.