UNPKG

6.25 kBMarkdownView Raw
1tmplconv
2==========
3
4<!---
5This file is generated by ape-tmpl. Do not update manually.
6--->
7
8<!-- Badge Start -->
9<a name="badges"></a>
10
11[![Build Status][bd_travis_shield_url]][bd_travis_url]
12[![npm Version][bd_npm_shield_url]][bd_npm_url]
13[![JS Standard][bd_standard_shield_url]][bd_standard_url]
14
15[bd_repo_url]: https://github.com/okunishinishi/node-tmplconv
16[bd_travis_url]: http://travis-ci.org/okunishinishi/node-tmplconv
17[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-tmplconv.svg?style=flat
18[bd_travis_com_url]: http://travis-ci.com/okunishinishi/node-tmplconv
19[bd_travis_com_shield_url]: https://api.travis-ci.com/okunishinishi/node-tmplconv.svg?token=
20[bd_license_url]: https://github.com/okunishinishi/node-tmplconv/blob/master/LICENSE
21[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-tmplconv
22[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-tmplconv.svg?style=flat
23[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-tmplconv.svg?style=flat
24[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-tmplconv
25[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-tmplconv.svg
26[bd_npm_url]: http://www.npmjs.org/package/tmplconv
27[bd_npm_shield_url]: http://img.shields.io/npm/v/tmplconv.svg?style=flat
28[bd_standard_url]: http://standardjs.com/
29[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
30
31<!-- Badge End -->
32
33
34<!-- Description Start -->
35<a name="description"></a>
36
37Two way template converter.
38
39<!-- Description End -->
40
41
42<!-- Overview Start -->
43<a name="overview"></a>
44
45
46**my_awesome_func.js**
47```
48function myAwesomeFunc () {
49 /* ... */
50}
51```
52
53&nbsp;&nbsp; &darr;&darr; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &uarr;&uarr;
54
55Tmplify &nbsp;&nbsp; Render
56
57&nbsp;&nbsp; &darr;&darr; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &uarr;&uarr;
58
59**____name<span></span>@snakecase____.js.tmpl**
60
61```
62function ____name@camelcase____ () {
63 /* ... */
64}
65```
66
67
68<!-- Overview End -->
69
70
71<!-- Sections Start -->
72<a name="sections"></a>
73
74<!-- Section from "doc/guides/01.Installation.md.hbs" Start -->
75
76<a name="section-doc-guides-01-installation-md"></a>
77
78Installation
79-----
80
81```bash
82npm install tmplconv --save-dev
83```
84
85
86<!-- Section from "doc/guides/01.Installation.md.hbs" End -->
87
88<!-- Section from "doc/guides/02.Render.md.hbs" Start -->
89
90<a name="section-doc-guides-02-render-md"></a>
91
92Render Files from Template
93---------
94
95```javascript
96'use strict'
97
98const tmplconv = require('tmplconv')
99
100// Render files from existing template
101tmplconv.render('asset/app-tmpl', 'demo/demo-app', {
102 // Data to render
103 data: {
104 'name': 'my-awesome-app',
105 'description': "This is an example for the app templates."
106 }
107}).then((result) => {
108 /* ... */
109})
110
111```
112
113##### Render Options
114
115| Key | Default | Description |
116| --- | --- | --- |
117| data | | Name or path of data module. |
118| pattern | '**/*.*' | File name patterns |
119| ignore | | File name patterns to ignore |
120| prefix | '_____' | Embed prefix |
121| suffix | '_____' | Embed suffix |
122| extname | '.tmpl' | Embed Template extension name |
123| silent | | Disable console logs |
124| clean | | Cleanup destination directory before convert |
125| once | | Write only first time. Skip if already exists |
126| mode | '644' | File permission to generate |
127
128
129
130<!-- Section from "doc/guides/02.Render.md.hbs" End -->
131
132<!-- Section from "doc/guides/03.Templify.md.hbs" Start -->
133
134<a name="section-doc-guides-03-templify-md"></a>
135
136Generate Template from Existing Files
137---------
138
139```javascript
140'use strict'
141
142const tmplconv = require('tmplconv')
143
144// Generate template from existing directory
145tmplconv.tmplify('demo/demo-app', 'asset/app-tmpl', {
146 // Patterns of files to tmplify
147 pattern: [
148 'lib/*.js',
149 'test/*_test.js'
150 ],
151 // Rule to tmplify
152 data: {
153 'name': 'my-awesome-app',
154 'description': "This is an example for the app templates."
155 }
156}).then((result) => {
157 /* ... */
158})
159
160```
161
162##### Tmplify options
163| Key | Default | Description |
164| --- | --- | --- |
165| data | | Name or path of data module. |
166| pattern | '**/*.*' | File name patterns |
167| ignore | | File name patterns to ignore |
168| prefix | '_____' | Embed prefix |
169| suffix | '_____' | Embed suffix |
170| extname | '.tmpl' | Embed Template extension name |
171| silent | | Disable console logs |
172| clean | | Cleanup destination directory before convert |
173| once | | Write only first time. Skip if already exists |
174| mode | '644' | File permission to generate |
175
176
177<!-- Section from "doc/guides/03.Templify.md.hbs" End -->
178
179<!-- Section from "doc/guides/04.Conversion.md.hbs" Start -->
180
181<a name="section-doc-guides-04-conversion-md"></a>
182
183#### String Conversion
184
185
186You can use these functions to convert text before it is inserted into a template:
187
188* __camelcase:__ "hello world" --> "HelloWorld"
189* __pascalcase:__ "hello world" --> "helloWorld"
190* __spinalcase:__ "hello world" --> "hello-world"
191* __snakecase:__ "hello world" --> "hello_world"
192* __uppercase:__ "hello world" --> "HELLO WORLD"
193* __lowercase:__ "hello world" --> "hello world"
194* __enumcase:__ "hello world" --> "hello:world"
195
196
197<!-- Section from "doc/guides/04.Conversion.md.hbs" End -->
198
199<!-- Section from "doc/guides/05.CLI.md.hbs" Start -->
200
201<a name="section-doc-guides-05-cli-md"></a>
202
203Using with CLI
204---------
205
206Install as a global module.
207
208```bash
209$ npm install tmplconv -g
210```
211
212#### CLI Usage:
213
214```bash
215$ tmplconv -h
216Usage: tmplconv [options] [command]
217
218Two way template converter.
219
220Options:
221 -V, --version output the version number
222 -h, --help output usage information
223
224Commands:
225 tmplify [options] <srcDir> <destDir> Generate a template from existing files
226 render [options] <srcDir> <destDir>
227 transplant [options] <src> <dest> Tmplify and render at once
228
229```
230
231<!-- Section from "doc/guides/05.CLI.md.hbs" End -->
232
233
234<!-- Sections Start -->
235
236
237<!-- LICENSE Start -->
238<a name="license"></a>
239
240License
241-------
242This software is released under the [MIT License](https://github.com/okunishinishi/node-tmplconv/blob/master/LICENSE).
243
244<!-- LICENSE End -->
245
246