Skip to content

Commit 0652664

Browse files
committed
change template engine to doT
1 parent 0cfb6c7 commit 0652664

9 files changed

+626
-1577
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
coverage
33
npm-debug.log
4+
report.html

dist/easygooglemaps.js

+314-1,556
Large diffs are not rendered by default.

dist/easygooglemaps.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<script type="text/underscorejs" id="infobox">
9494
<div class="baloon"> <button class="baloon__close js-infobox-close"></button>
9595
<div className="baloon__content">
96-
<%= title %>
96+
{{=baloon.title}}
9797
</div>
9898
</div>
9999
</script>

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@
5656
},
5757
"license": "MIT",
5858
"dependencies": {
59+
"dot": "^1.1.1",
5960
"google-maps": "^3.2.1",
6061
"google-maps-infobox": "^1.1.14",
61-
"underscore": "^1.8.3"
62+
"handlebars": "^4.0.6",
63+
"json-loader": "^0.5.4",
64+
"webpack-bundle-analyzer": "^2.3.0"
6265
}
6366
}

readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ MyMap.init();
6464
items: [
6565
{
6666
"content": {
67-
// this is <%= title %> in html template
67+
// this is {{=baloon.title}} in html template
6868
"title": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolore, consequatur."
6969
},
7070
"marker": {
@@ -91,12 +91,12 @@ MyMap.init();
9191
}
9292
}
9393
```
94-
And also HTML template (underscore) for infobox should be specified:
94+
And also HTML template (doT) for infobox should be specified:
9595
```html
9696
<script type="text/underscorejs" id="infobox">
9797
<div class="baloon"> <button class="baloon__close js-infobox-close"></button>
9898
<div className="baloon__content">
99-
<%= title %>
99+
{{=baloon.title}}
100100
</div>
101101
</div>
102102
</script>

src/easygooglemaps.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* @name EasyGoogleMaps
66
*/
77

8-
import {template} from 'underscore';
98
import GoogleMapsLoader from 'google-maps';
9+
import dot from 'dot';
1010

1111

1212
export default (function() {
@@ -84,7 +84,8 @@
8484

8585
_getTemplate() {
8686
let HTML = document.querySelector(this._props.infobox.template).innerHTML;
87-
return template(HTML);
87+
dot.templateSettings.varname = 'baloon';
88+
return dot.template(HTML);
8889
}
8990

9091

webpack.config.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
var webpack = require('webpack');
22
var minimize = process.argv.indexOf('--no-minimize') === -1 ? true : false;
3-
var plugins = minimize ? [new webpack.optimize.UglifyJsPlugin({
3+
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
4+
var plugins = minimize ? [
5+
new webpack.optimize.UglifyJsPlugin({
46
minimize: true,
57
compress: {
68
drop_console: true
79
},
8-
}),new webpack.optimize.MinChunkSizePlugin({minChunkSize: '100000'})] : [new webpack.optimize.MinChunkSizePlugin({minChunkSize: '100000'})];
10+
}),
11+
new webpack.optimize.MinChunkSizePlugin({minChunkSize: '100000'}),
12+
new BundleAnalyzerPlugin( {
13+
analyzerMode: 'static',
14+
analyzerPort: 4000,
15+
openAnalyzer: false
16+
}
17+
)
18+
] : [
19+
new webpack.optimize.MinChunkSizePlugin({minChunkSize: '100000'})
20+
];
921

1022
module.exports = {
23+
node: {
24+
console: 'empty',
25+
fs: 'empty',
26+
net: 'empty',
27+
tls: 'empty'
28+
},
1129
entry: {
1230
'dist/easygooglemaps':'./src/easygooglemaps.js'
1331
},
@@ -22,7 +40,10 @@ module.exports = {
2240
test: /\.js?$/,
2341
exclude: /(node_modules|bower_components)/,
2442
loader: 'babel'
25-
}]
43+
},{
44+
test: /\.json$/,
45+
loader: 'json'
46+
}]
2647
},
2748
plugins: plugins
2849
};

0 commit comments

Comments
 (0)