javascriptejsscaffoldingmetalsmithmoleculer

Moleculer-Cli inspired project: how to use EJS instead of Handlebars


I'm trying to create some scaffolding tool to easily start a project the way I want. I like the way how guys from moleculer do it in their https://github.com/moleculerjs/moleculer-cli

They use Handlebars so now I can do this in my template (for example the one for package.json):

"name" : "{{ projectName }}"

That worked well but I would prefer to use ejs. Unfortunately, I can't figure out how to successfully change the init.js file so Metalsmith can chew up something like this:

"name" : "<%= projectName %>}}"

Solution

  • The moleculer-cli uses consolidate package which supports ejs, as well.

    So, you should change the render variable here: const render = require("consolidate").handlebars.render;