Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Enable handlebars helpers when rendering preview #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require("babel-register")({
]
});

const Handlebars = require('handlebars');
const HandlebarsAdapter = require('@frctl/handlebars');
const React = require('react');
const ReactDOM = require('react-dom/server');
const Promise = require('bluebird');
Expand All @@ -18,6 +18,9 @@ class ReactAdapter extends Adapter {

constructor(source, loadPaths) {
super(null, source);

// Create a HandlebarsAdapter for rendering layouts
this.hbsAdapter = HandlebarsAdapter({}).register(source, source._app);
}

render(path, str, context){
Expand All @@ -29,8 +32,7 @@ class ReactAdapter extends Adapter {
}

renderLayout(path, str, context){
const template = Handlebars.compile(str);
return Promise.resolve(template(context));
return this.hbsAdapter.render(path, str, context);
}

}
Expand Down