From 4764cd69dc522175fda4a6ddf579982e1ab55801 Mon Sep 17 00:00:00 2001 From: ah-adarlow Date: Thu, 25 May 2017 08:55:48 -0400 Subject: [PATCH] Enable handlebars helpers when rendering preview Replaces the Handlebars template engine with a HandlebarsAdapter. --- adapter.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adapter.js b/adapter.js index 9886aae..277b8ce 100644 --- a/adapter.js +++ b/adapter.js @@ -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'); @@ -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){ @@ -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); } }