@lassehaslev/templater

0.2.3 • Public • Published

@lassehaslev/templater

CLI (Command Line Interface) template engine for all sorts of files

Install

npm install @lassehaslev/templater --save

Usage

Templater takes 2 parameters

  1. Inquirer.js objects (Array)
  2. 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'! );
} );

Templates

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.

Example file
<?php

/**
 * Class TestFile
 * @author <% author.name %> <<% author.email %>>
 */
class TestFile
{
}

This will render

<?php

/**
 * Class TestFile
 * @author My name <your@email.com>
 */
class TestFile
{
}

Readme

Keywords

Package Sidebar

Install

npm i @lassehaslev/templater

Weekly Downloads

0

Version

0.2.3

License

MIT

Last publish

Collaborators

  • lassehaslev