Have ideas to improve npm?Join in the discussion! »

tmplconv

2.0.1 • Public • Published

tmplconv

Build Status Code Climate Code Coverage npm Version

Two way template converter.

my_awesome_func.js

function myAwesomeFunc () {
    /*...*/
}

   ↓↓            ↑↑

Render    Tmplify

   ↓↓            ↑↑

name@snakecase.js.tmpl

function ____name@camelcase____ () {
    /*...*/
}

Installation

npm install tmplconv --save-dev

Render

var tmplconv = require('tmplconv');
 
tmplconv.render('asset/app-tmpl', 'demo/demo-app', {
    data: {
        'name': 'my-awesome-app',
        'description': "This is an example for the app templates."
    }
}, function (err) {
    /*...*/
});
 
Render Options
Key Default Description
data Name or path of data module.
pattern '**/.' File name patterns
ignore File name patterns to ignore
prefix '_____' Embed prefix
suffix '_____' Embed suffix
extname '.tmpl' Embed Template extension name
silent Disable console logs
clean Cleanup destination directory before convert
once Write only first time. Skip if already exists
mode '644' File permission to generate

Templify

var tmplconv = require('tmplconv');
 
tmplconv.tmplify('demo/demo-app', 'asset/app-tmpl', {
    pattern: [
        'lib/*.js',
        'test/*_test.js'
    ],
    data: {
        'name': 'my-awesome-app',
        'description': "This is an example for the app templates."
    }
}, function (err) {
    /*...*/
});
 
Tmplify options
Key Default Description
data Name or path of data module.
pattern '**/.' File name patterns
ignore File name patterns to ignore
prefix '_____' Embed prefix
suffix '_____' Embed suffix
extname '.tmpl' Embed Template extension name
silent Disable console logs
clean Cleanup destination directory before convert
once Write only first time. Skip if already exists
mode '644' File permission to generate

Using with CLI

Install as a global module.

$ npm install tmplconv -g

CLI Usage:

$ tmplconv -h
 
  Usage: tmplconv [options] [command]
 
 
  Commands:
 
    tmplify [options] <srcDir> <destDir>  Generate a template from existing files
    render [options] <srcDir> <destDir> 
    transplant [options] <src> <dest>     Tmplify and render at once
 
  Two way template converter.
 
  Options:
 
    -h, --help     output usage information
    -V, --version  output the version number
 
 

License

This software is released under the MIT License.

Install

npm i [email protected]

Version

2.0.1

License

MIT

Last publish

Collaborators

  • avatar