本文整理匯總了TypeScript中ejs.renderFile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript renderFile函數的具體用法?TypeScript renderFile怎麽用?TypeScript renderFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了renderFile函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: renderFile
return new Promise<string>((resolve, reject) => {
renderFile(source, replacements, (err: Error, str: string) => {
if (err) {
reject(err);
}
resolve(str);
});
});
示例2: reject
return new Promise<string>((resolve, reject) => {
ejs.renderFile(filePath, data, opts, (error, file) => {
if (error) {
reject(error)
} else {
resolve(file!)
}
})
})
示例3: next
const renderIndex = (req: Request, res: Response, next: Function) => {
ejs.renderFile(path.join(ProjectPath.FrontendFolder, req['localePath'], 'index.html'),
res.tpl, (err, str) => {
if (err) {
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, err.message));
}
res.send(str);
});
};
示例4: generateFromTemplate
private generateFromTemplate(options : api.IGenerateOptions, schema : api.ISchema, templateName : string, callback : (err : Error) => void) : void {
console.log("Generating " + templateName);
var opt = null;
var data = { schema: schema, options: options.generatorOptions };
var dir = this.getTemplateDir(options, __dirname);
var templatePath: string = path.join(dir, templateName);
var self = this;
ejs.renderFile(templatePath, data, opt, function(err, str){
var genText : string = str;
genText = self.translateReferences(genText, options);
var baseName = path.basename(templateName, ".ejs");
fs.writeFileSync(path.join(options.targetDirectory, baseName), genText);
callback(null);
});
}