Blaze.renderWithData && contentBlock


#1

How can i set contentBlock for view created via Blaze API ?


#2

Interesting question!

I poked around in the blaze repo and the only reference I could find was this:

Which makes me think you could try creating a view, assigning a templateContentBlock to that view, and then rendering it?

// Create an uninitialized view
const view = new Blaze.View(Template.myTemplate);

// I assume contentFunc can be any kind of renderable content, like a Template object.
// see: http://blazejs.org/api/blaze.html#Renderable-Content
const contentFunc = Template.exampleTemplate;
view.templateContentBlock = new Blaze.Template('(contentBlock)', contentFunc);

// Render it!
Blaze.render(view, document.body);

Now I haven’t tested any of the above, that’s just my thoughts after looking at Blaze’s internals, so give it a try and let me know how you go