CLI (Command Line Interface) template engine for all sorts of files
npm install @lassehaslev/templater --save
Templater takes 2 parameters
- Inquirer.js objects (Array)
- Options (Object)
templateFolder
default:__dirname + '/../templates'
- What folder to find templates
folder
default:process.argv[2] || './'
- Where to add new templates
#! /usr/bin/env node
var Templater = require( '@lassehaslev/templater' );
var templater = new Templater([
{
type: 'input',
name: 'author.name',
message: 'Whats your name?',
default: 'My name',
},
{
type: 'input',
name: 'author.email',
message: 'Whats your email?',
default: 'your@email.com',
},
], {
templateFolder: __dirname + '/../templates',
});
templater.start().then( function( response ) {
console.log( 'All complete'! );
} );
You can add any files in this folder. All files and folders/subfolders added in this folder will be copied to destination and rendered with new variables.
Use <% variable.name %>
syntax to edit your variables.
<?php
/**
* Class TestFile
* @author <% author.name %> <<% author.email %>>
*/
class TestFile
{
}
This will render
<?php
/**
* Class TestFile
* @author My name <your@email.com>
*/
class TestFile
{
}