本文整理汇总了TypeScript中less.render函数的典型用法代码示例。如果您正苦于以下问题:TypeScript render函数的具体用法?TypeScript render怎么用?TypeScript render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: compile
exports.compile = function compile(buffer, stream) {
var m = less.render(buffer, function (e, css) {
if (e)
throw new Error(e);
stream.write(css);
});
};
开发者ID:jspdown,项目名称:webkool,代码行数:7,代码来源:less.ts
示例2: switch
const compile_and_resolve_deps = (input: {code: string, lang: string, file: string}) => {
let code: string
switch (input.lang) {
case "coffeescript":
try {
code = coffee.compile(input.code, {bare: true, shiftLine: true})
} catch (error) {
return reply({error: mkCoffeescriptError(error, input.file)})
}
break;
case "javascript":
case "typescript":
code = input.code
break;
case "less":
const options = {
paths: [path.dirname(input.file)],
compress: true,
ieCompat: false,
}
less.render(input.code, options, (error: any, output: any) => {
if (error != null)
reply({error: mkLessError(error, input.file)})
else
reply({code: output.css})
})
return
default:
throw new Error(`unsupported input type: ${input.lang}`)
}
const result = ts.transpileModule(code, {
fileName: input.file,
reportDiagnostics: true,
compilerOptions: {
noEmitOnError: false,
noImplicitAny: false,
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
},
})
if (result.diagnostics != null && result.diagnostics.length > 0) {
const diagnostic = result.diagnostics[0]
return reply({error: mkTypeScriptError(diagnostic)})
}
const source = result.outputText
try {
const deps = detective(source)
return reply({ code: source, deps: deps })
} catch(error) {
return reply({error: error})
}
}
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:57,代码来源:compile.ts
示例3: less
function less(input: Buffer, options: LessOptions, callback: TransformCallback) {
const input_string = input.toString('utf8');
less_module.render(input_string, options, (less_error, less_output) => {
if (less_error) {
const error = new Error(less_error.message)
Object.assign(error, less_error)
return callback(error);
}
const output = new Buffer(less_output.css, 'utf8');
callback(null, output);
});
}
开发者ID:chbrown,项目名称:fapply,代码行数:13,代码来源:applicators.ts
示例4: render
render(data) {
let newLessStyles = data.less;
for (let key in data.theme) {
newLessStyles = newLessStyles.replace(new RegExp(variableRegexPrefix + key + variableRegexPostfix), () => {
return '@' + key + ': ' + data.theme[key] + ';';
});
}
Less.render(newLessStyles, (e, result) => {
if (result !== undefined) {
this.reply({
method: 'render',
css: result.css
});
}
});
}
开发者ID:emmberk,项目名称:ddf,代码行数:16,代码来源:worker.less.ts
示例5: task
task("styles:build", async () => {
for (const src of paths.less.sources) {
const {css} = await less.render(read(src)!, {filename: src})
write(rename(src, {dir: paths.build_dir.css, ext: ".css"}), css)
}
})
开发者ID:HuntJSparra,项目名称:bokeh,代码行数:6,代码来源:styles.ts
示例6: render
// .less
const less = {
render(
source: string,
map: any | null,
options: any
): StylePreprocessorResults {
const nodeLess = require('less')
let result: any
let error: Error | null = null
nodeLess.render(
source,
{ syncImport: true },
(err: Error | null, output: any) => {
error = err
result = output
}
)
if (error) return { code: '', errors: [error] }
if (map) {
return {
code: result.css.toString(),
map: merge(map, result.map),
errors: []
}
}
return { code: result.css.toString(), errors: [] }
开发者ID:gilFuser,项目名称:gilFuser.github.io,代码行数:31,代码来源:index.ts
示例7: render
// .less
const less = {
render(
source: string,
map: any | null,
options: any
): StylePreprocessorResults {
const nodeLess = require('less')
let result: any
let error: Error | null = null
nodeLess.render(
source,
Object.assign({}, options, { syncImport: true }),
(err: Error | null, output: any) => {
error = err
result = output
}
)
if (error) return { code: '', errors: [error] }
if (map) {
return {
code: result.css.toString(),
map: merge(map, result.map),
errors: []
}
}
return { code: result.css.toString(), errors: [] }
开发者ID:aldCom,项目名称:aldCom.github.io,代码行数:31,代码来源:index.ts
注:本文中的less.render函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论