How to use the render function from less
Find comprehensive JavaScript less.render code examples handpicked from public code repositorys.
83 84 85 86 87 88 89 90 91 92
})(`./build/themes/V3/${dir}/style.css`); } await fs.outputFile('./themes/themes.json', JSON.stringify(themes, null, 2)); // await less.render(lessCode, { // compress : !dev, // sourceMap : (dev ? { // sourceMapFileInline: true, // outputSourceFiles: true
+ 11 other calls in file
GitHub: putaoshu/jdf
![putaoshu profile picture](/putaoshu.png?size=40)
63 64 65 66 67 68 69 70 71 72
return; } if($.is.less(source) && jdf.config.build.less){ try{ Less.render(sourceContent, {filename: source, syncImport:true}, function(error, output){ if(error){ console.log(error); }else{ var targetContent = output.css;
+ 3 other calls in file
GitHub: thumbsup/thumbsup
![thumbsup profile picture](/thumbsup.png?size=40)
107 108 109 110 111 112 113 114 115 116
const customInclude = this.customStylesInclude() // now render both together const lessOptions = { paths: [this.dir] } less.render(themeLess + customInclude, lessOptions, (err, output) => { if (err) return done(err) const filename = this.opts.stylesheetName || 'theme.css' const dest = path.join(this.dest, 'public', filename) fs.mkdirpSync(path.join(this.dest, 'public'))
+ 3 other calls in file
195 196 197 198 199 200 201 202 203 204
filename: lessPath, paths: options.preprocess.importPaths(options.render.paths, req) }); lessSrc = options.preprocess.less(lessSrc, req); less.render(lessSrc, renderOptions, function(err, output){ if (err) { utilities.lessError(err); return next(err); }
+ 3 other calls in file
87 88 89 90 91 92 93 94 95 96
const isProductionEnv = process.env.NODE_ENV === 'production'; const processLess = function(context, payload) { return new Promise(( resolve, reject ) => { less.render({ file: context }, function(err, result) { if( !err ) { resolve(result);
+ 7 other calls in file
GitHub: qlik-oss/leonardo-ui
![qlik-oss profile picture](/qlik-oss.png?size=40)
129 130 131 132 133 134 135 136 137 138
function compileLess() { const lessContent = fs.readFileSync(path.resolve(docsDir, 'src/docs.less'), { encoding: 'utf8', }); less.render( lessContent, { paths: [path.resolve(__dirname, '../src')], filename: 'docs.css',
+ 3 other calls in file
63 64 65 66 67 68 69 70 71 72
process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (less_css) { less.render(less_css, function(e, css){ console.log(css) }); }); """
+ 3 other calls in file
GitHub: everlose/nodePractice
![everlose profile picture](/everlose.png?size=40)
124 125 126 127 128 129 130 131 132 133
res.end(err.message); return; } var contentText = fs.readFileSync(path); less.render(contentText.toString(), { filename: path }, function(e, output) { if (e) { res.end(self.showError(e));
+ 3 other calls in file
76 77 78 79 80 81 82 83 84 85
return locals; } export default async function processLess(source, rootPath, filePath, camelCase, modulePath) { try { const lessResult = await less.render(source, { sourceMap: { outputSourceFiles: true }, relativeUrls: true,
+ 3 other calls in file
33 34 35 36 37 38 39 40 41
} }; }; async function compileLess (file, minify) { return less.render(await fs.readFileAsync(file, 'utf8'), { filename: file, strictMath: true }).then((output) => { return minify ? minifyCss(output.css) : output.css; }); }
GitHub: Linkontoask/radishes
![Linkontoask profile picture](/Linkontoask.png?size=40)
36 37 38 39 40 41 42 43 44 45
} const lessSource = `.css { ${content} }` let { css } = await less.render(lessSource) css = css.split('\n') content = '' for (let i = 0; i < css.length; i++) {
+ 3 other calls in file
GitHub: jaredly/demobox
![jaredly profile picture](/jaredly.png?size=40)
19 20 21 22 23 24 25 26 27
main: main[i], accent: accent[i], accentLight: accentLight[i] }) var name = names[i].toLowerCase().replace(' ', '-') less.render(text, { paths: ['.'], compress: true, filename: name }, save.bind(null, '../build/themes/' + name + '.css')) }
+ 3 other calls in file
GitHub: stolksdorf/vitreum
![stolksdorf profile picture](/stolksdorf.png?size=40)
10 11 12 13 14 15 16 17 18 19
const transform = (code, fp, opts)=>imports.add(fp); transform.generate = async (dev=false)=>{ clearLessCache(); const lessCode = Array.from(imports).reverse().map((fp)=>`@import (less) "${fp}";`).join('\n'); return await LessLib.render(lessCode, { compress : !dev, sourceMap : (dev ? { sourceMapFileInline: true, outputSourceFiles: true
GitHub: versionone/wess
![versionone profile picture](/versionone.png?size=40)
24 25 26 27 28 29 30 31 32 33
function read(done) { fs.readFile(path, 'utf8', done); } // Compile the source. // Use the less.render() promise interface because the regular one appears // to occasionally call the callback multiple times. function compile(source, done) { less.render(source, opts) .then(function(output) { done(null, output); },
+ 11 other calls in file
GitHub: drsounds/liberal
![drsounds profile picture](/drsounds.png?size=40)
95 96 97 98 99 100 101 102 103 104
darkTheme = darkTheme.replace(/\@secondary-color/, settings.secondaryColor); darkTheme = darkTheme.replace("@islight", true ? '@light' : '@dark'); darkTheme = darkTheme.replace("@isdark", !true ? '@light' : '@dark'); //alert(theme); less.render(lightTheme, {}, function (error, output) { console.log(error, output); //alert(output); fs.writeFileSync(process.env.PWD + '/themes/' + settings.theme + '/css/light.css', output.css); });
+ 7 other calls in file
GitHub: tcurdt/xstatic
![tcurdt profile picture](/tcurdt.png?size=40)
18 19 20 21 22 23 24 25 26 27
}, defaults) const collection = new Xstatic.collection('less', [ files ], options) function less(file, doc, resolver) { return Less.render(doc.body.data.toString(), _.merge(options.less, { plugins: [ resolver ], filename: Path.resolve(file.path), relativeUrls: false, })).then(function(result) {
GitHub: serendipityApe/fect
![serendipityApe profile picture](/serendipityApe.png?size=40)
24 25 26 27 28 29 30 31 32 33
}, } const compileLess = async (filePath) => { const source = await readFile(filePath, 'utf8') const { css } = await render(source, { filename: filePath, plugins: [TildeResolverPlugin], }) return css
67 68 69 70 71 72 73 74 75 76
// process less content let processed; try { processed = await less.render(input, options); } catch (error) { console.log( `[${blue('.scripts/less')}] ${red( 'An error occurred while processing styles'
+ 6 other calls in file
223 224 225 226 227 228 229 230 231 232 233
files: scripts, }, fork); }; actions.buildCSS = async function buildCSS(data) { const lessOutput = await less.render(data.source, { paths: data.paths, javascriptEnabled: false, });
+ 3 other calls in file
GitHub: llleeeaaannn/bohsforum
238 239 240 241 242 243 244 245 246 247
async function saveRenderedCss(data) { if (!data.customCSS) { return; } const less = require('less'); const lessObject = await less.render(data.customCSS, { compress: true, javascriptEnabled: false, }); data.renderedCustomCSS = lessObject.css;
less.render is the most popular function in less (129 examples)