Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lassehaslev/templater

CLI (Command Line Interface) template engine for all sorts of files
https://github.com/lassehaslev/templater

cli cli-app nodejs productivity template templater utility

Last synced: 4 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# @lassehaslev/templater
> CLI (Command Line Interface) template engine for all sorts of files

## Install
```bash
npm install @lassehaslev/templater --save
```

## Usage
Templater takes 2 parameters
1. [Inquirer.js objects](https://github.com/sboudrias/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

```js
#! /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: '[email protected]',
},
], {
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
<<% author.email %>>
*/
class TestFile
{
}
```

*This will render*
```php

*/
class TestFile
{
}
```