I want to use Handlebars to add content to emails before they get sent, all of this happening on the server. We are using Dreamfactory and we can run scripts in Javascript to pre/post-process requests coming from the client (example: http://wiki.dreamfactory.com/DreamFactory/Tutorials/V8_custom_scripting_service_math)
I have uploaded handlebars-v4.0.11.js to the server, renamed it handlebars.js, and it fails on the first example given on the Handlebars website. Here is the code:
var Handlebars = require('../../../handlebars.js');
var source = `<div class="entry">
<h1>{{title}}</h1>
<div class="body">
{{body}}
</div>
</div>`;
var template = Handlebars.compile(source);
var context = {
title: 'My New Post',
body: 'This is my first post!'
};
var html = template(context);
It fails with the message "Unknown template object: object"
What could I do?