Skip to content

Commit

Permalink
rename import silent to import mute. Fixes less#1210
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Jul 5, 2013
1 parent dce4524 commit f4902f8
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- support for import inline option to include css that you do not want less to parse e.g. `@import (inline) "file.css";`
- better support for modifyVars (refresh styles with new variables, using a file cache), is now more resiliant
- support for import silent option to reference external css, but not output it. Any mixin calls or extend's will be output.
- support for import mute option to reference external css, but not output it. Any mixin calls or extend's will be output.

# 1.4.1

Expand Down
2 changes: 1 addition & 1 deletion lib/less/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// 'currentDirectory' - path to the current file, absolute
// 'rootFilename' - filename of the base file
// 'entryPath' - absolute path to the entry file
// 'silent' - whether the file should be silent and only output parts that are referenced
// 'mute' - whether the file should be mute and only output parts that are referenced

tree.parseEnv = function(options) {
copyFromOriginal(options, this, parseCopyProperties);
Expand Down
2 changes: 1 addition & 1 deletion lib/less/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var less = {
},
writeError: function (ctx, options) {
options = options || {};
if (options.silent) { return }
if (options.silent) { return; }
sys.error(less.formatError(ctx, options));
}
};
Expand Down
6 changes: 3 additions & 3 deletions lib/less/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ less.Parser = function Parser(env) {
newEnv.processImports = false;
newEnv.contents[fullPath] = contents;

if (currentFileInfo.silent || importOptions.silent) {
newFileInfo.silent = true;
if (currentFileInfo.mute || importOptions.mute) {
newFileInfo.mute = true;
}

if (importOptions.inline) {
Expand Down Expand Up @@ -1321,7 +1321,7 @@ less.Parser = function Parser(env) {
},

importOption: function() {
var opt = $(/^(less|css|multiple|once|inline|silent)/);
var opt = $(/^(less|css|multiple|once|inline|mute)/);
if (opt) {
return opt[1];
}
Expand Down
6 changes: 3 additions & 3 deletions lib/less/tree/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ tree.Comment = function (value, silent, index, currentFileInfo) {
tree.Comment.prototype = {
type: "Comment",
toCSS: function (env) {
return (env.compress || (this.currentFileInfo && this.currentFileInfo.silent && !this.isNotSilent)) ? '' : this.value;
return (env.compress || (this.currentFileInfo && this.currentFileInfo.mute && !this.isNotMute)) ? '' : this.value;
},
eval: function () { return this; },
markNotSilent: function () {
this.isNotSilent = true;
markNotMute: function () {
this.isNotMute = true;
}
};

Expand Down
10 changes: 5 additions & 5 deletions lib/less/tree/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tree.Directive.prototype = {
},
toCSS: function (env) {

if (this.currentFileInfo.silent && !this.isNotSilent) {
if (this.currentFileInfo.mute && !this.isNotMute) {
return "";
}

Expand All @@ -45,14 +45,14 @@ tree.Directive.prototype = {
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) },
markNotSilent: function () {
markNotMute: function () {
var rule, i;
this.isNotSilent = true;
this.isNotMute = true;
if (this.ruleset) {
for (i = 0; i < this.ruleset.rules.length; i++) {
rule = this.ruleset.rules[i];
if (rule.markNotSilent) {
rule.markNotSilent();
if (rule.markNotMute) {
rule.markNotMute();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/less/tree/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ tree.Media.prototype = {
var el = new(tree.Element)('', '&', 0);
return [new(tree.Selector)([el], null, this.index, this.currentFileInfo)];
},
markNotSilent: function () {
markNotMute: function () {
var rule, i;
this.isNotSilent = true;
this.isNotMute = true;
for (i = 0; i < this.ruleset.rules.length; i++) {
rule = this.ruleset.rules[i];
if (rule.markNotSilent) {
rule.markNotSilent();
if (rule.markNotMute) {
rule.markNotMute();
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions lib/less/tree/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ tree.mixin.Call.prototype = {
}
}
if (match) {
if (!this.currentFileInfo || !this.currentFileInfo.silent) {
if (!this.currentFileInfo || !this.currentFileInfo.mute) {
for (i = 0; i < rules.length; i++) {
rule = rules[i];
if (rule.markNotSilent) {
rule.markNotSilent();
if (rule.markNotMute) {
rule.markNotMute();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/less/tree/ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ tree.Ruleset.prototype = {
.filter(function(p) {
var i;
for(i = 0; i < p.length; i++) {
if (!p[i].isSilent()) {
if (!p[i].isMute()) {
return true;
}
return false;
Expand Down Expand Up @@ -278,9 +278,9 @@ tree.Ruleset.prototype = {
return css.join('') + (env.compress ? '\n' : '');
},

markNotSilent: function () {
markNotMute: function () {
for (var s = 0; s < this.selectors.length; s++) {
this.selectors[s].markNotSilent();
this.selectors[s].markNotMute();
}
},

Expand Down
14 changes: 7 additions & 7 deletions lib/less/tree/selector.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (tree) {

tree.Selector = function (elements, extendList, index, currentFileInfo, isNotSilent) {
tree.Selector = function (elements, extendList, index, currentFileInfo, isNotMute) {
this.elements = elements;
this.extendList = extendList || [];
this.currentFileInfo = currentFileInfo || {};
this.isNotSilent = isNotSilent;
this.isNotMute = isNotMute;
};
tree.Selector.prototype = {
type: "Selector",
Expand All @@ -13,7 +13,7 @@ tree.Selector.prototype = {
this.extendList = visitor.visit(this.extendList)
},
createDerived: function(elements, extendList) {
return new(tree.Selector)(elements, extendList || this.extendList, this.index, this.currentFileInfo, this.isNotSilent);
return new(tree.Selector)(elements, extendList || this.extendList, this.index, this.currentFileInfo, this.isNotMute);
},
match: function (other) {
var elements = this.elements,
Expand Down Expand Up @@ -62,11 +62,11 @@ tree.Selector.prototype = {

return this._css;
},
markNotSilent: function () {
this.isNotSilent = true;
markNotMute: function () {
this.isNotMute = true;
},
isSilent: function() {
return this.currentFileInfo.silent && !this.isNotSilent;
isMute: function() {
return this.currentFileInfo.mute && !this.isNotMute;
}
};

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions test/less/import-silent.less → test/less/import-mute.less
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@import (silent) url("import-once.less");
@import (silent) url("css-3.less");
@import (silent) url("media.less");
@import (mute) url("import-once.less");
@import (mute) url("css-3.less");
@import (mute) url("media.less");
/*
The media statement above is invalid (no selector)
We should ban invalid media queries with properties and no selector?
*/
@import (silent) url("import/import-silent.less");
@import (mute) url("import/import-mute.less");

.b {
.z();
Expand Down
File renamed without changes.

0 comments on commit f4902f8

Please sign in to comment.