Skip to content

Commit

Permalink
support jsWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Oct 15, 2015
1 parent 4cfa370 commit 0556fd9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
16 changes: 8 additions & 8 deletions lib/main.js
Expand Up @@ -98,7 +98,7 @@ function getTypeFromClassIdMapAndKey(classIdMap, key) {
return type;
}

exports.getJsCode = function (classIdMap, modName, mapFilter,jsWrapper) {
exports.getJsCode = function (classIdMap, modName, mapFilter, jsWrapper) {
var code;
if (mapFilter) {
code = JSON.stringify(classIdMap, function (k, v) {
Expand Down Expand Up @@ -126,14 +126,14 @@ exports.getJsCode = function (classIdMap, modName, mapFilter,jsWrapper) {
}
if (modName !== undefined) {
return my_js_beautify('module.exports = ( ' + (modName ? ('"' + modName + '"') : '') +
'function(){ return ' + code + '; });');
}else if(jsWrapper !=undefined){
return my_js_beautify(jsWrapper.replace("{{code}}",code));
'function(){ return ' + code + '; });');
} else if (jsWrapper != undefined) {
return my_js_beautify(jsWrapper.replace("{{code}}", code));
}
return my_js_beautify('CLASS_ID_MAP=' + code + ';');
};

exports.getDevJsCode = function (classIdMap, modName,jsWrapper) {
exports.getDevJsCode = function (classIdMap, modName, jsWrapper) {
var code;
var map = {};
for (var k in classIdMap) {
Expand All @@ -144,9 +144,9 @@ exports.getDevJsCode = function (classIdMap, modName,jsWrapper) {
code = JSON.stringify(map);
if (modName !== undefined) {
return my_js_beautify('module.exports = ( ' + (modName ? ('"' + modName + '"') : '') +
'function(){ return ' + code + '; });');
}else if(jsWrapper !=undefined){
return my_js_beautify(jsWrapper.replace("{{code}}",code));
'function(){ return ' + code + '; });');
} else if (jsWrapper != undefined) {
return my_js_beautify(jsWrapper.replace("{{code}}", code));
}
return my_js_beautify('CLASS_ID_MAP=' + code + ';');
};
Expand Down
63 changes: 33 additions & 30 deletions package.json
@@ -1,33 +1,36 @@
{
"name": "class-id-minifier",
"version": "0.3.4",
"description": "minify class and id attribute in html",
"author": "yiminghe <yiminghe@gmail.com>",
"bugs": {
"url": "https://github.com/yiminghe/class-id-minifier"
},
"engines": {
"node": ">=0.8.0"
},
"bin": {
"ci-minify": "./bin/minify.js"
},
"directories": {
"lib": "./lib/"
},
"main": "./lib/main.js",
"dependencies": {
"optimist": ">=0.3.4",
"iconv-lite": ">=0.2.0",
"js-beautify": ">=0.2.0"
},
"licenses": [
{
"type": "MIT"
}
],
"repository": {
"type": "git",
"url": "git://github.com/yiminghe/Sugar.git"
"name": "class-id-minifier",
"version": "0.4.0",
"description": "minify class and id attribute in html",
"author": "yiminghe <yiminghe@gmail.com>",
"bugs": {
"url": "https://github.com/yiminghe/class-id-minifier"
},
"engines": {
"node": ">=0.8.0"
},
"bin": {
"ci-minify": "./bin/minify.js"
},
"directories": {
"lib": "./lib/"
},
"main": "./lib/main.js",
"dependencies": {
"optimist": ">=0.3.4",
"iconv-lite": ">=0.2.0",
"js-beautify": ">=0.2.0"
},
"licenses": [
{
"type": "MIT"
}
],
"repository": {
"type": "git",
"url": "git://github.com/yiminghe/Sugar.git"
},
"scripts": {
"publish": "git push origin"
}
}

0 comments on commit 0556fd9

Please sign in to comment.