Skip to content

Commit d8d7443

Browse files
committed
update README.md
1 parent f9a93e3 commit d8d7443

File tree

5 files changed

+140
-7
lines changed

5 files changed

+140
-7
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ const template = data => `
4545
```
4646

4747
``` javascript
48-
// babel => uglify
49-
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"};
48+
// source => babel
49+
var template = function template(data) {
50+
return '\n <!-- section start -->\n <section>\n <h3>' + data.title + '</h3>\n <div>' + data.date + '</div>\n <dl>\n <dt>Coffee</dt>\n <dt>Black hot drink</dt>\n <dt>Milk</dt>\n <dd>\n <ul>\n ' + data.list.map(function (item) {
51+
return '\n <li>' + item + '</li>\n ';
52+
}).join('') + '\n </ul>\n </dd>\n </dl>\n </section>\n <!-- section end -->\n';
53+
};
5054
```
5155

5256
``` javascript
53-
// babel => template-string-optimize => uglify
54-
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>"};
57+
// source => babel => template-string-optimize
58+
var template = function template(data) {
59+
return '<section><h3>' + data.title + '</h3><div>' + data.date + '</div><dl><dt>Coffee</dt><dt>Black hot drink</dt><dt>Milk</dt><dd><ul>' + data.list.map(function (item) {
60+
return '<li>' + item + '</li>';
61+
}).join('') + '</ul></dd></dl></section>';
62+
};
5563
```
5664

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "template string optimize loader module for webpack",
55
"main": "index.js",
66
"scripts": {
7-
"test": " webpack -p && webpack -p --config webpack.config.optimize.js"
7+
"test": " webpack && webpack --config webpack.config.optimize.js"
88
},
99
"author": "chenjiahan",
1010
"license": "ISC",

test/dist/test.js

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
1-
!function(n){function t(i){if(e[i])return e[i].exports;var d=e[i]={exports:{},id:i,loaded:!1};return n[i].call(d.exports,d,d.exports,t),d.loaded=!0,d.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([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"};document.body.innerHTML=e({title:"title",date:"2000-01-01",list:["item1","item2","item3"]})}]);
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ exports: {},
15+
/******/ id: moduleId,
16+
/******/ loaded: false
17+
/******/ };
18+
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
22+
/******/ // Flag the module as loaded
23+
/******/ module.loaded = true;
24+
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
29+
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
36+
/******/ // __webpack_public_path__
37+
/******/ __webpack_require__.p = "";
38+
39+
/******/ // Load entry module and return exports
40+
/******/ return __webpack_require__(0);
41+
/******/ })
42+
/************************************************************************/
43+
/******/ ([
44+
/* 0 */
45+
/***/ function(module, exports) {
46+
47+
'use strict';
48+
49+
var reg = /\n1323<!-- 123 -->/;
50+
var template = function template(data) {
51+
return '\n <!-- section start -->\n <section>\n <h3>' + data.title + '</h3>\n <div>' + data.date + '</div>\n <dl>\n <dt>Coffee</dt>\n <dt>Black hot drink</dt>\n <dt>Milk</dt>\n <dd>\n <ul>\n ' + data.list.map(function (item) {
52+
return '\n <li>' + item + '</li>\n ';
53+
}).join('') + '\n </ul>\n </dd>\n </dl>\n </section>\n <!-- section end -->\n';
54+
};
55+
56+
document.body.innerHTML = template({
57+
title: 'title',
58+
date: '2000-01-01',
59+
list: ['item1', 'item2', 'item3']
60+
});
61+
62+
/***/ }
63+
/******/ ]);

test/dist/test.min.js

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
1-
!function(t){function e(d){if(i[d])return i[d].exports;var n=i[d]={exports:{},id:d,loaded:!1};return t[d].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([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>"};document.body.innerHTML=i({title:"title",date:"2000-01-01",list:["item1","item2","item3"]})}]);
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ exports: {},
15+
/******/ id: moduleId,
16+
/******/ loaded: false
17+
/******/ };
18+
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
22+
/******/ // Flag the module as loaded
23+
/******/ module.loaded = true;
24+
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
29+
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
36+
/******/ // __webpack_public_path__
37+
/******/ __webpack_require__.p = "";
38+
39+
/******/ // Load entry module and return exports
40+
/******/ return __webpack_require__(0);
41+
/******/ })
42+
/************************************************************************/
43+
/******/ ([
44+
/* 0 */
45+
/***/ function(module, exports) {
46+
47+
'use strict';
48+
49+
var reg = /1323/;
50+
var template = function template(data) {
51+
return '<section><h3>' + data.title + '</h3><div>' + data.date + '</div><dl><dt>Coffee</dt><dt>Black hot drink</dt><dt>Milk</dt><dd><ul>' + data.list.map(function (item) {
52+
return '<li>' + item + '</li>';
53+
}).join('') + '</ul></dd></dl></section>';
54+
};
55+
56+
document.body.innerHTML = template({
57+
title: 'title',
58+
date: '2000-01-01',
59+
list: ['item1', 'item2', 'item3']
60+
});
61+
62+
/***/ }
63+
/******/ ]);

test/src/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var reg = /\n1323<!-- 123 -->/;
12
const template = data => `
23
<!-- section start -->
34
<section>

0 commit comments

Comments
 (0)