Skip to content

Commit 5a81716

Browse files
committed
Merge pull request #733 from varya/features/extend-in-less
Support extends in LESS with newest Gonzales-PE (Fix #726)
2 parents 2653bc1 + 692f192 commit 5a81716

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

lib/modules/kss-splitter.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ module.exports = {
5555
}
5656
// Extend current block content
5757
block.type = type;
58-
block.content += nodes.toCSS(syntax);
59-
//console.log(block.content);
58+
block.content += nodes.toString(syntax);
6059
prevNode = nodes;
6160
}
6261
}]);

lib/modules/parsers/less.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function parseVariableDeclarations(string) {
3333
if (element.type === 'operator' && element.content === ':') {
3434
return;
3535
}
36-
varVal += element.toCSS('less'); // Syntax is always less as this visitor is only for LESS
36+
varVal += element.toString('less'); // Syntax is always less as this visitor is only for LESS
3737
});
3838

3939
out.push({
@@ -118,7 +118,7 @@ function setVariables(string, variables) {
118118
}
119119
});
120120
});
121-
return ast.toCSS('less');
121+
return ast.toString('less');
122122
}
123123

124124
module.exports = {

lib/modules/parsers/scss.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function parseVariableDeclarations(string) {
2727
if (nodes.content[3]) {
2828
out.push({
2929
name: varName,
30-
value: nodes.content[3].toCSS(syntax),
30+
value: nodes.content[3].toString(syntax),
3131
line: nodes.content[3].start.line
3232
});
3333
}
@@ -85,7 +85,7 @@ function setVariables(string, variables) {
8585
});
8686
});
8787

88-
return ast.toCSS(syntax);
88+
return ast.toString(syntax);
8989
}
9090

9191
module.exports = {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"css": "~2.2.0",
3737
"express": "~4.13.0",
3838
"fs-extra": "^0.20.0",
39-
"gonzales-pe": "3.0.0-29",
39+
"gonzales-pe": "3.0.0-31",
4040
"gulp": "~3.9.0",
4141
"gulp-concat": "~2.5.2",
4242
"gulp-mustache": "~1.0.2",

test/unit/vendors/gonzales.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,30 @@ $a: cell((1.75));
6666
});
6767
});
6868

69+
describe('LESS', function() {
70+
71+
it('should parse extends', function() {
72+
var str = multiline(function() {
73+
/*
74+
.animal {
75+
background-color: black;
76+
color: white;
77+
}
78+
.bear {
79+
&:extend(.animal);
80+
background-color: brown;
81+
}
82+
*/
83+
});
84+
85+
ast = gonzales.parse(str, {
86+
syntax: 'less'
87+
});
88+
expect(ast).to.be.an('object');
89+
});
90+
91+
});
92+
6993
it('should return error message with invalid syntax', function(done) {
7094
var invalid = '$a = foo', msg;
7195
try {

0 commit comments

Comments
 (0)