UNPKG

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