0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-10 22:24:19 +01:00

enhance customizer to handle transitive Less @import-s

This commit is contained in:
Chris Rebert 2014-03-27 21:28:21 -07:00
parent 1853e31a10
commit 07314b5475

View File

@ -181,10 +181,20 @@ window.onload = function () { // wait for load in a dumb way because B-0
var IMPORT_REGEX = /^@import \"(.*?)\";$/ var IMPORT_REGEX = /^@import \"(.*?)\";$/
var lessLines = __less[lessFilename].split('\n') var lessLines = __less[lessFilename].split('\n')
for (var i = 0, imports = []; i < lessLines.length; i++) { var imports = []
var match = IMPORT_REGEX.exec(lessLines[i]) $.each(lessLines, function (index, lessLine) {
if (match) imports.push(match[1]) var match = IMPORT_REGEX.exec(lessLine)
if (match) {
var importee = match[1]
var transitiveImports = includedLessFilenames(importee)
$.each(transitiveImports, function (index, transitiveImportee) {
if ($.inArray(transitiveImportee, imports) === -1) {
imports.push(transitiveImportee)
} }
})
imports.push(importee)
}
})
return imports return imports
} }
@ -192,7 +202,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
function generateLESS(lessFilename, lessFileIncludes, vars) { function generateLESS(lessFilename, lessFileIncludes, vars) {
var lessSource = __less[lessFilename] var lessSource = __less[lessFilename]
$.each(includedLessFilenames(lessFilename), function(index, filename) { var lessFilenames = includedLessFilenames(lessFilename)
$.each(lessFilenames, function(index, filename) {
var fileInclude = lessFileIncludes[filename] var fileInclude = lessFileIncludes[filename]
// Files not explicitly unchecked are compiled into the final stylesheet. // Files not explicitly unchecked are compiled into the final stylesheet.