Skip to content

Commit 9235e23

Browse files
committed
update README.md
1 parent a95c129 commit 9235e23

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,48 @@
11
# template-string-optimize-loader
22
template string optimize loader module for webpack
33

4-
## Install
4+
## Installation
55

6-
npm install template-string-optimize-loader
6+
npm install template-string-optimize-loader --save-dev
7+
8+
## Usage
9+
10+
module: {
11+
loaders: [
12+
{
13+
test: /\.js$/,
14+
loader: 'template-string-optimize!babel'
15+
}
16+
]
17+
}
18+
19+
## Example
20+
21+
// ES6
22+
const template = data => `
23+
<!-- section start -->
24+
<section>
25+
<h3>${data.title}</h3>
26+
<div>${data.date}</div>
27+
<dl>
28+
<dt>Coffee</dt>
29+
<dt>Black hot drink</dt>
30+
<dt>Milk</dt>
31+
<dd>
32+
<ul>
33+
${data.list.map((item) => `
34+
<li>${item}</li>
35+
`).join('')}
36+
</ul>
37+
</dd>
38+
</dl>
39+
</section>
40+
<!-- section end -->
41+
`;
42+
43+
// ES5
44+
function(n,t){"use strict";var e=function(n){return"\n <!-- section start -->\n <section>\n <h3>"+n.title+"</h3>\n <div>"+n.date+"</div>\n <dl>\n <dt>Coffee</dt>\n <dt>Black hot drink</dt>\n <dt>Milk</dt>\n <dd>\n <ul>\n "+n.list.map(function(n){return"\n <li>"+n+"</li>\n "}).join("")+"\n </ul>\n </dd>\n </dl>\n </section>\n <!-- section end -->\n"};
45+
46+
// optimized
47+
function(t,e){"use strict";var i=function(t){return"<section><h3>"+t.title+"</h3><div>"+t.date+"</div><dl><dt>Coffee</dt><dt>Black hot drink</dt><dt>Milk</dt><dd><ul>"+t.list.map(function(t){return"<li>"+t+"</li>"}).join("")+"</ul></dd></dl></section>"};
48+

test/dist/test.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)