Reputation: 683
I'd rather not have to type out each field name of my ejs file. Here is what i'd like to do:
let html = null;
EJS.renderFile('./public/views/results.ejs', {JSON_OBJECT}, (err, str) => {
html = str;
});
Upvotes: 4
Views: 723
Reputation: 529
Something encapsulated in {} will create a new object.
So in
var JSON_OBJECT = {test: "value"};
var obj2 = {JSON_OBJECT}
obj2 will be an object with a property named JSON_OBJECT, which in itself has a property test.
EJS.renderFile accepts a JSON object as its second parameter. The properties the object can contain are described in the package description of ejs.
Upvotes: 5