Add import inline option. Fixes #1209

This commit is contained in:
Luke Page
2013-03-19 15:20:46 +00:00
parent 08fca7a7cc
commit 6fc6dc2301
7 changed files with 41 additions and 32 deletions

View File

@@ -20,8 +20,8 @@ tree.Import = function (path, features, options, index, currentFileInfo) {
this.features = features;
this.currentFileInfo = currentFileInfo;
if (this.options.less !== undefined) {
this.css = !this.options.less;
if (this.options.less !== undefined || this.options.inline) {
this.css = !this.options.less || this.options.inline;
} else {
var pathValue = this.getPath();
if (pathValue && /css([\?;].*)?$/.test(pathValue)) {
@@ -44,7 +44,9 @@ tree.Import.prototype = {
accept: function (visitor) {
this.features = visitor.visit(this.features);
this.path = visitor.visit(this.path);
this.root = visitor.visit(this.root);
if (!this.options.inline) {
this.root = visitor.visit(this.root);
}
},
toCSS: function (env) {
var features = this.features ? ' ' + this.features.toCSS(env) : '';
@@ -84,7 +86,10 @@ tree.Import.prototype = {
if (this.skip) { return []; }
if (this.css) {
if (this.options.inline) {
var contents = new(tree.Anonymous)(this.root);
return this.features ? new(tree.Media)([contents], this.features.value) : [contents];
} else if (this.css) {
var newImport = new(tree.Import)(this.evalPath(env), features, this.options, this.index);
if (!newImport.css && this.error) {
throw this.error;