MCPcopy
hub / github.com/less/less.js / render

Function render

packages/less/lib/less/render.js:4–38  ·  view source on GitHub ↗
(input, options, callback)

Source from the content-addressed store, hash-verified

2
3export default function(environment, ParseTree) {
4 const render = function (input, options, callback) {
5 if (typeof options === 'function') {
6 callback = options;
7 options = utils.copyOptions(this.options, {});
8 }
9 else {
10 options = utils.copyOptions(this.options, options || {});
11 }
12
13 if (!callback) {
14 const self = this;
15 return new Promise(function (resolve, reject) {
16 render.call(self, input, options, function(err, output) {
17 if (err) {
18 reject(err);
19 } else {
20 resolve(output);
21 }
22 });
23 });
24 } else {
25 this.parse(input, options, function(err, root, imports, options) {
26 if (err) { return callback(err); }
27
28 let result;
29 try {
30 const parseTree = new ParseTree(root, imports);
31 result = parseTree.toCSS(options);
32 }
33 catch (err) { return callback(err); }
34
35 callback(null, result);
36 });
37 }
38 };
39
40 return render;
41}

Callers

nothing calls this directly

Calls 2

toCSSMethod · 0.95
callMethod · 0.80

Tested by

no test coverage detected