[SOLVED] Blaze.render() with Template.contentBlock?

Hello all! I’m trying to create template views dynamically, so that I can trigger modals etc. more easily. Basically, the idea is that I can have a universal window template, like this:

<template name="windowFrame">
  <div class="framing-classes">

Then you could have the content of a specific window defined in another template:

<template name="myWindow">
  <p>Various stuff and whatnot</p>

So what I want to do is have a single bit of javascript which will attach Template.windowFrame to the DOM, with Template.myWindow as its contentBlock. Something like:

function makeWindow(contentTemplate, data) {
  var container = Blaze.View("window", function() {
    return Template.windowFrame;
  container.templateContentBlock = Blaze.With(data, function() {
    return Template[contentTemplate];
  Blaze.render(container, document.body);

// render Template.windowFrame with Template.myWindow inside it:

makeWindow("myWindow", {title:"Fancy Title"});

Unfortunately, this doesn’t work. The rendered View always has its templateContentBlock set to null. Haven’t been able to get around this. Any suggestions?

Are you looking for something like Template.dynamic? http://docs.meteor.com/#/full/template_dynamic

Yes, I was, but I couldn’t quite figure out how to do it. The inimitable @dbarrett figured it out, however: https://gist.github.com/devonbarrett/ecbdcde710fbdab980c7