Skip to content

Commit ff9aa1c

Browse files
Merge pull request #46 from maximkoretskiy/drop-lodash-templatest
Drop lodash templates
2 parents bc8f1f6 + 725f076 commit ff9aa1c

File tree

4 files changed

+17
-3113
lines changed

4 files changed

+17
-3113
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
npm-debug.log
33
.vscode/
4+
yarn.lock

lib/rules-fabric.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
var template = require('lodash.template');
21
var decls = require('./decls.json');
32

3+
function template(string, data) {
4+
return string.replace(/\$\{([\w\-\.]*)\}/g, function (_str, key) {
5+
var v = data[key];
6+
return typeof v !== 'undefined' && v !== null ? v : '';
7+
});
8+
}
9+
410
/*
511
Rules legend:
612
- combined - if rule is combined it will be rendered with template
@@ -23,8 +29,7 @@ function _compileDecls(inputDecls) {
2329
var templateVars = _getRulesMap(inputDecls);
2430
return inputDecls.map(function (decl) {
2531
if (decl.combined && decl.initial) {
26-
var t = template(decl.initial.replace(/\-/g, ''));
27-
decl.initial = t(templateVars);
32+
decl.initial = template(decl.initial.replace(/\-/g, ''), templateVars);
2833
}
2934
return decl;
3035
});
@@ -33,8 +38,8 @@ function _compileDecls(inputDecls) {
3338
function _getRequirements(inputDecls) {
3439
return inputDecls.reduce(function (map, decl) {
3540
if (!decl.contains) return map;
36-
return decl.contains.reduce(function (mapInner, dependensy) {
37-
mapInner[dependensy] = decl;
41+
return decl.contains.reduce(function (mapInner, dependency) {
42+
mapInner[dependency] = decl;
3843
return mapInner;
3944
}, map);
4045
}, {});
@@ -46,11 +51,11 @@ function _expandContainments(inputDecls) {
4651
.filter(function (decl) {
4752
return !decl.contains;
4853
}).map(function (decl) {
49-
var dependensy = requiredMap[decl.prop];
50-
if (dependensy) {
51-
decl.requiredBy = dependensy.prop;
52-
decl.basic = decl.basic || dependensy.basic;
53-
decl.inherited = decl.inherited || dependensy.inherited;
54+
var dependency = requiredMap[decl.prop];
55+
if (dependency) {
56+
decl.requiredBy = dependency.prop;
57+
decl.basic = decl.basic || dependency.basic;
58+
decl.inherited = decl.inherited || dependency.inherited;
5459
}
5560
return decl;
5661
});

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
"type": "git",
1515
"url": "https://github.com/maximkoretskiy/postcss-initial.git"
1616
},
17-
"dependencies": {
18-
"lodash.template": "^4.5.0"
19-
},
17+
"dependencies": {},
2018
"peerDependencies": {
2119
"postcss": "^8.0.0"
2220
},

0 commit comments

Comments
 (0)