Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okunishinishi/node-tmplconv
Node.js module to convert template in two ways.
https://github.com/okunishinishi/node-tmplconv
scaffold
Last synced: 2 months ago
JSON representation
Node.js module to convert template in two ways.
- Host: GitHub
- URL: https://github.com/okunishinishi/node-tmplconv
- Owner: okunishinishi
- License: mit
- Created: 2015-09-12T18:33:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T18:13:42.000Z (about 2 years ago)
- Last Synced: 2024-04-26T07:22:13.958Z (9 months ago)
- Topics: scaffold
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/tmplconv
- Size: 498 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tmplconv
==========[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[![JS Standard][bd_standard_shield_url]][bd_standard_url][bd_repo_url]: https://github.com/okunishinishi/node-tmplconv
[bd_travis_url]: http://travis-ci.org/okunishinishi/node-tmplconv
[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-tmplconv.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/okunishinishi/node-tmplconv
[bd_travis_com_shield_url]: https://api.travis-ci.com/okunishinishi/node-tmplconv.svg?token=
[bd_license_url]: https://github.com/okunishinishi/node-tmplconv/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-tmplconv
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-tmplconv.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-tmplconv.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-tmplconv
[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-tmplconv.svg
[bd_npm_url]: http://www.npmjs.org/package/tmplconv
[bd_npm_shield_url]: http://img.shields.io/npm/v/tmplconv.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svgTwo way template converter.
**my_awesome_func.js**
```
function myAwesomeFunc () {
/* ... */
}
```↓↓ ↑↑
Tmplify Render
↓↓ ↑↑
**____name@snakecase____.js.tmpl**
```
function ____name@camelcase____ () {
/* ... */
}
```Installation
-----```bash
npm install tmplconv --save-dev
```Render Files from Template
---------```javascript
'use strict'const tmplconv = require('tmplconv')
// Render files from existing template
tmplconv.render('asset/app-tmpl', 'demo/demo-app', {
// Data to render
data: {
'name': 'my-awesome-app',
'description': "This is an example for the app templates."
}
}).then((result) => {
/* ... */
})```
##### 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 |Generate Template from Existing Files
---------```javascript
'use strict'const tmplconv = require('tmplconv')
// Generate template from existing directory
tmplconv.tmplify('demo/demo-app', 'asset/app-tmpl', {
// Patterns of files to tmplify
pattern: [
'lib/*.js',
'test/*_test.js'
],
// Rule to tmplify
data: {
'name': 'my-awesome-app',
'description': "This is an example for the app templates."
}
}).then((result) => {
/* ... */
})```
##### 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 |#### String Conversion
You can use these functions to convert text before it is inserted into a template:
* __camelcase:__ "hello world" --> "HelloWorld"
* __pascalcase:__ "hello world" --> "helloWorld"
* __spinalcase:__ "hello world" --> "hello-world"
* __snakecase:__ "hello world" --> "hello_world"
* __uppercase:__ "hello world" --> "HELLO WORLD"
* __lowercase:__ "hello world" --> "hello world"
* __enumcase:__ "hello world" --> "hello:world"Using with CLI
---------Install as a global module.
```bash
$ npm install tmplconv -g
```#### CLI Usage:
```bash
$ tmplconv -h
Usage: tmplconv [options] [command]Two way template converter.
Options:
-V, --version output the version number
-h, --help output usage informationCommands:
tmplify [options] Generate a template from existing files
render [options]
transplant [options] Tmplify and render at once```
License
-------
This software is released under the [MIT License](https://github.com/okunishinishi/node-tmplconv/blob/master/LICENSE).