add banner option. Fixes #1735
This commit is contained in:
Родитель
fdf666fe22
Коммит
479827b02f
|
@ -351,20 +351,22 @@ less.Parser = function Parser(env) {
|
|||
// @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
|
||||
//
|
||||
parse: function (str, callback, additionalData) {
|
||||
var root, line, lines, error = null, globalVars, modifyVars;
|
||||
var root, line, lines, error = null, globalVars, modifyVars, preText = "";
|
||||
|
||||
i = j = currentPos = furthest = 0;
|
||||
|
||||
globalVars = (additionalData && additionalData.globalVars) ? less.Parser.serializeVars(additionalData.globalVars) + '\n' : '';
|
||||
modifyVars = (additionalData && additionalData.modifyVars) ? '\n' + less.Parser.serializeVars(additionalData.modifyVars) : '';
|
||||
|
||||
if (globalVars || (additionalData && additionalData.banner)) {
|
||||
preText = ((additionalData && additionalData.banner) ? additionalData.banner : "") + globalVars;
|
||||
parser.imports.contentsIgnoredChars[env.currentFileInfo.filename] = preText.length;
|
||||
}
|
||||
|
||||
str = str.replace(/\r\n/g, '\n');
|
||||
// Remove potential UTF Byte Order Mark
|
||||
input = str = globalVars + str.replace(/^\uFEFF/, '') + modifyVars;
|
||||
|
||||
input = str = preText + str.replace(/^\uFEFF/, '') + modifyVars;
|
||||
parser.imports.contents[env.currentFileInfo.filename] = str;
|
||||
if (globalVars) {
|
||||
parser.imports.contentsIgnoredChars[env.currentFileInfo.filename] = globalVars.length;
|
||||
}
|
||||
|
||||
// Split the input into chunks.
|
||||
chunks = (function (input) {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/**
|
||||
* Test
|
||||
*/
|
||||
#header {
|
||||
color: #333333;
|
||||
border-left: 1px;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/**
|
||||
* Test
|
||||
*/
|
||||
.class {
|
||||
color: #ff0000;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ lessTester.runTestSet({strictMath: true, strictUnits: true, sourceMap: true, glo
|
|||
}
|
||||
return path.join('test/sourcemaps', filename) + '.json';
|
||||
});
|
||||
lessTester.runTestSet({globalVars: true}, "globalVars/",
|
||||
lessTester.runTestSet({globalVars: true, banner: "/**\n * Test\n */\n"}, "globalVars/",
|
||||
null, null, null, function(name) { return path.join('test/less/', name) + '.json'; });
|
||||
lessTester.runTestSet({modifyVars: true}, "modifyVars/",
|
||||
null, null, null, function(name) { return path.join('test/less/', name) + '.json'; });
|
||||
|
|
|
@ -217,6 +217,9 @@ module.exports = function() {
|
|||
} else if (options.modifyVars) {
|
||||
additionalData.modifyVars = options.getVars(path);
|
||||
}
|
||||
if (options.banner) {
|
||||
additionalData.banner = options.banner;
|
||||
}
|
||||
parser.parse(str, function (err, tree) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
|
|
Загрузка…
Ссылка в новой задаче