Implement postProcessor callback feature for less.ls browser environment #1835

Add `jasmine:postProcessor` task and corresponding spec as well
This commit is contained in:
Cloud Chen
2014-02-03 00:02:49 +08:00
parent eb19ae4cfa
commit 0a7954355a
6 changed files with 36 additions and 2 deletions

View File

@@ -159,6 +159,13 @@ function createCSS(styles, sheet, lastModified) {
}
}
function postProcessCSS(styles) {
if (less.postProcessor && typeof less.postProcessor === 'function') {
styles = less.postProcessor.call(styles, styles) || styles;
}
return styles;
}
function errorHTML(e, rootHref) {
var id = 'less-error-message:' + extractId(rootHref || "");
var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
@@ -575,7 +582,9 @@ function initRunningMode(){
if (e) {
error(e, sheet.href);
} else if (root) {
createCSS(root.toCSS(less), sheet, env.lastModified);
var styles = root.toCSS(less);
styles = postProcessCSS(styles);
createCSS(styles, sheet, env.lastModified);
}
});
}
@@ -645,7 +654,9 @@ less.refresh = function (reload, modifyVars) {
log("loading " + sheet.href + " from cache.", logLevel.info);
} else {
log("parsed " + sheet.href + " successfully.", logLevel.info);
createCSS(root.toCSS(less), sheet, env.lastModified);
var styles = root.toCSS(less);
styles = postProcessCSS(styles);
createCSS(styles, sheet, env.lastModified);
}
log("css for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms', logLevel.info);
if (env.remaining === 0) {