Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extends in LESS with newest Gonzales-PE (Fix #726) #733

Merged
merged 3 commits into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/modules/kss-splitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ module.exports = {
}
// Extend current block content
block.type = type;
block.content += nodes.toCSS(syntax);
//console.log(block.content);
block.content += nodes.toString(syntax);
prevNode = nodes;
}
}]);
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/parsers/less.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function parseVariableDeclarations(string) {
if (element.type === 'operator' && element.content === ':') {
return;
}
varVal += element.toCSS('less'); // Syntax is always less as this visitor is only for LESS
varVal += element.toString('less'); // Syntax is always less as this visitor is only for LESS
});

out.push({
Expand Down Expand Up @@ -118,7 +118,7 @@ function setVariables(string, variables) {
}
});
});
return ast.toCSS('less');
return ast.toString('less');
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/parsers/scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function parseVariableDeclarations(string) {
if (nodes.content[3]) {
out.push({
name: varName,
value: nodes.content[3].toCSS(syntax),
value: nodes.content[3].toString(syntax),
line: nodes.content[3].start.line
});
}
Expand Down Expand Up @@ -85,7 +85,7 @@ function setVariables(string, variables) {
});
});

return ast.toCSS(syntax);
return ast.toString(syntax);
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"css": "~2.2.0",
"express": "~4.13.0",
"fs-extra": "^0.20.0",
"gonzales-pe": "3.0.0-29",
"gonzales-pe": "3.0.0-31",
"gulp": "~3.9.0",
"gulp-concat": "~2.5.2",
"gulp-mustache": "~1.0.2",
Expand Down
24 changes: 24 additions & 0 deletions test/unit/vendors/gonzales.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,30 @@ $a: cell((1.75));
});
});

describe('LESS', function() {

it('should parse extends', function() {
var str = multiline(function() {
/*
.animal {
background-color: black;
color: white;
}
.bear {
&:extend(.animal);
background-color: brown;
}
*/
});

ast = gonzales.parse(str, {
syntax: 'less'
});
expect(ast).to.be.an('object');
});

});

it('should return error message with invalid syntax', function(done) {
var invalid = '$a = foo', msg;
try {
Expand Down