1 | tmplconv
|
2 | ==========
|
3 |
|
4 |
|
5 | This file is generated by ape-tmpl. Do not update manually.
|
6 | --->
|
7 |
|
8 |
|
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 |
|
32 |
|
33 |
|
34 |
|
35 | <a name="description"></a>
|
36 |
|
37 | Two way template converter.
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | <a name="overview"></a>
|
44 |
|
45 |
|
46 | **my_awesome_func.js**
|
47 | ```
|
48 | function myAwesomeFunc () {
|
49 | /* ... */
|
50 | }
|
51 | ```
|
52 |
|
53 | ↓↓ ↑↑
|
54 |
|
55 | Tmplify Render
|
56 |
|
57 | ↓↓ ↑↑
|
58 |
|
59 | **____name<span></span>@snakecase____.js.tmpl**
|
60 |
|
61 | ```
|
62 | function ____name@camelcase____ () {
|
63 | /* ... */
|
64 | }
|
65 | ```
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | <a name="sections"></a>
|
73 |
|
74 |
|
75 |
|
76 | <a name="section-doc-guides-01-installation-md"></a>
|
77 |
|
78 | Installation
|
79 | -----
|
80 |
|
81 | ```bash
|
82 | npm install tmplconv --save-dev
|
83 | ```
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | <a name="section-doc-guides-02-render-md"></a>
|
91 |
|
92 | Render Files from Template
|
93 | ---------
|
94 |
|
95 | ```javascript
|
96 | 'use strict'
|
97 |
|
98 | const tmplconv = require('tmplconv')
|
99 |
|
100 | // Render files from existing template
|
101 | tmplconv.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 |
|
131 |
|
132 |
|
133 |
|
134 | <a name="section-doc-guides-03-templify-md"></a>
|
135 |
|
136 | Generate Template from Existing Files
|
137 | ---------
|
138 |
|
139 | ```javascript
|
140 | 'use strict'
|
141 |
|
142 | const tmplconv = require('tmplconv')
|
143 |
|
144 | // Generate template from existing directory
|
145 | tmplconv.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 |
|
178 |
|
179 |
|
180 |
|
181 | <a name="section-doc-guides-04-conversion-md"></a>
|
182 |
|
183 | #### String Conversion
|
184 |
|
185 |
|
186 | You 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 |
|
198 |
|
199 |
|
200 |
|
201 | <a name="section-doc-guides-05-cli-md"></a>
|
202 |
|
203 | Using with CLI
|
204 | ---------
|
205 |
|
206 | Install as a global module.
|
207 |
|
208 | ```bash
|
209 | $ npm install tmplconv -g
|
210 | ```
|
211 |
|
212 | #### CLI Usage:
|
213 |
|
214 | ```bash
|
215 | $ tmplconv -h
|
216 | Usage: tmplconv [options] [command]
|
217 |
|
218 | Two way template converter.
|
219 |
|
220 | Options:
|
221 | -V, --version output the version number
|
222 | -h, --help output usage information
|
223 |
|
224 | Commands:
|
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 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 | <a name="license"></a>
|
239 |
|
240 | License
|
241 | -------
|
242 | This software is released under the [MIT License](https://github.com/okunishinishi/node-tmplconv/blob/master/LICENSE).
|
243 |
|
244 |
|
245 |
|
246 |
|