Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable passing Template objects to BlazeLayout.render #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akanix42
Copy link

@akanix42 akanix42 commented Jul 22, 2016

Currently, if you pass a template object in (instead of a string) as the layout to BlazeLayout.render, you receive an error because blaze-layout attempts to lookup the template by name.
If you pass in the template object (instead of a string) as data to BlazeLayout.render, the template doesn't render because the ReactiveDict stringifies the object.
Adding a simple check for layout template objects and switching to ReactiveMap for the data keeps the existing functionality for strings while allowing Templates to be passed in.

This can be used for vanilla Blaze, although its primarily useful for my Blaze Modules package where Blaze templates can be imported:

import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import layout from './client/layout/layout';
import homePage from './client/homePage/homePage';

BlazeLayout.render(layout, { content: homePage });

With vanilla Blaze:

import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Template } from 'meteor/templating';
import './client/layout/layout.html';
import './client/homePage/homePage.html';

BlazeLayout.render(Template.layout, { content: Template.homePage });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant