Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Supporting unlimited chained @import now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Engel committed Dec 22, 2011
1 parent d6fe89f commit 858bf62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
41 changes: 25 additions & 16 deletions Resources/js/app.js
Expand Up @@ -410,6 +410,30 @@ var app = {
}
},

find_constraints: function(file_object){
app.debug('Finding constraints for: '+file_object);
var source = file_object.open().read().toString(),
parent = fixfile(file_object.parent()),
re = /@import.+?"(.+?)"/g,
result,
constraints = [],
path_obj;

while (result = re.exec(source)) {
path_obj = parent.grep(result[1]);
if (path_obj.exists()) {
constraints.push({
last_stamp: path_obj.modificationTimestamp(),
title: result[1],
obj: path_obj
});
constraints = constraints.concat(app.find_constraints(path_obj));
}
}

return constraints;
},

/**
* This function takes a file object of a LESS file and does the following:
* 1: Checking if the file is already indexed
Expand Down Expand Up @@ -450,22 +474,7 @@ var app = {
}

//We have to load the source and parse search for any imports!
var source = file_object.open().read().toString(),
re = /@import.+?"(.+?)"/g,
result,
constraints = [],
path_obj;

while (result = re.exec(source)) {
path_obj = parent.grep(result[1]);
if (path_obj.exists()) {
constraints.push({
last_stamp: path_obj.modificationTimestamp(),
title: result[1],
obj: path_obj
});
}
}
var constraints = app.find_constraints(file_object);

console.log(constraints);

Expand Down
1 change: 1 addition & 0 deletions Resources/js/less.js
Expand Up @@ -2853,6 +2853,7 @@ function createCSS(styles, sheet, lastModified) {

function xhr(url, type, callback, errback) {
//If there is no file ending, LESS assumes you are trying to include a LESS file.
url = url.replace(/app:\/\/com.wearekiss.simpless.open\//g, '');
app.debug('LESS XHR: '+url);
if(url.substr(-4) != '.css' && url.substr(-5) != '.less') url += '.less';
var file = fixfile(app.compiling_file.infile.parent()).grep(url);
Expand Down

0 comments on commit 858bf62

Please sign in to comment.