本文整理汇总了TypeScript中handlebars.compile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript compile函数的具体用法?TypeScript compile怎么用?TypeScript compile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compile函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: populateTemplate
private populateTemplate(mailData: Mailer): Promise<Mailer> {
let deferred = Q.defer();
mailData.message = Handlebars.compile(mailData.template.html)(mailData.templateData);
mailData.template.subject = Handlebars.compile(mailData.template.subject)(mailData.templateData);
deferred.resolve(mailData);
return deferred.promise;
}
开发者ID:dangle0118,项目名称:mailing,代码行数:7,代码来源:mailer.ts
示例2: getTemplateFunction
getTemplateFunction() {
// Template compilation
// --------------------
// This demo uses Handlebars templates to render views.
// The template is loaded with Require.JS and stored as string on
// the view prototype. On rendering, it is compiled on the
// client-side. The compiled template function replaces the string
// on the view prototype.
//
// In the end you might want to precompile the templates to JavaScript
// functions on the server-side and just load the JavaScript code.
// Several precompilers create a global JST hash which stores the
// template functions. You can get the function by the template name:
//
// templateFunc = JST[@templateName];
let template = this.template;
let templateFunction: Function;
if (typeof template === 'string') {
// Compile the template string to a function and save it
// on the prototype. This is a workaround since an instance
// shouldn't change its prototype normally.
templateFunction = Handlebars.compile(template);
this.template = templateFunction;
} else if (typeof template === 'function') {
templateFunction = template;
}
return templateFunction;
}
开发者ID:fafnirical,项目名称:test--chaplin,代码行数:32,代码来源:view.ts
示例3: exportTexturePoolViaHandlebarsTemplate
function exportTexturePoolViaHandlebarsTemplate(
folderRootTo: string,
templateFolderAndFile: string,
data: any,
) {
let text = fs.readFileSync(templateFolderAndFile, 'utf8');
if (text && text.length > 0) {
text = text.replace(/\r/g, '');
const lines = text.split('\n');
if (lines.length > 1 && lines[0]) {
const resultFile = path.resolve(folderRootTo, lines[0]);
text = lines.slice(1).join('\n');
console.log(`${templateFolderAndFile} => ${resultFile}`);
const template = handlebars.compile(text);
if (template) {
fs.ensureDirSync(path.dirname(resultFile));
fs.writeFileSync(resultFile, template(data));
} else {
console.log('template error in ' + resultFile);
}
}
}
}
开发者ID:igor-bezkrovny,项目名称:texturer,代码行数:25,代码来源:meta.ts
示例4:
Marionette.TemplateCache.prototype.compileTemplate = (rawTemplate: any): any => {
if (_.isFunction(rawTemplate)) {
return rawTemplate;
} else {
return Handlebars.compile(rawTemplate);
}
};
开发者ID:fafnirical,项目名称:test--marionette,代码行数:7,代码来源:view.ts
示例5: _compileTemplate
private _compileTemplate(templatePath: string, data: Object) {
const templateFileName = path.join(process.cwd(), templatePath);
const templateFile = fs.readFileSync(templateFileName, 'UTF-8');
const templateFunc: Function = handlebars.compile(templateFile);
return templateFunc(data);
}
开发者ID:Uter1007,项目名称:sumobase.core,代码行数:7,代码来源:mail.service.ts
示例6: getFilesFrom
.then((data) => {
const [file, pack, meta] = data;
const connectionTypes = ['mainnet', 'testnet'];
if (!param.scripts) {
const sourceFiles = getFilesFrom(join(__dirname, '../src'), '.js', function (name, path) {
return !name.includes('.spec') && !path.includes('/test/');
});
param.scripts = meta.vendors.map((i) => join(__dirname, '..', i)).concat(sourceFiles);
param.scripts.push(join(__dirname, '../loginDaemon.js'));
}
if (!param.styles) {
param.styles = meta.stylesheets.map((i) => join(__dirname, '..', i)).concat(getFilesFrom(join(__dirname, '../src'), '.less'));
}
const networks = connectionTypes.reduce((result, item) => {
result[item] = meta.configurations[item];
return result;
}, Object.create(null));
return compile(file)({
pack: pack,
domain: meta.domain,
build: {
type: 'web'
},
network: networks[param.connection]
});
})
开发者ID:beregovoy68,项目名称:WavesGUI,代码行数:30,代码来源:utils.ts
示例7: function
handler: function(request, reply) {
let paths = getPaths(server, baseUri, filter);
let source = fs.readFileSync(__dirname + '/sitemap.xml.hbs', 'utf8');
let template = handlebars.compile(source);
reply(template({paths: paths}))
.type('application/xml');
},
开发者ID:csgpro,项目名称:csgpro.com,代码行数:8,代码来源:index.ts
示例8: subHandle
function subHandle(fullPath: string, args: any) {
wd = path.dirname(fullPath);
let tmpl = fs.readFileSync(fullPath, 'utf8');
var template = hbs.compile(tmpl.toString());
var result = template(args);
return result;
}
开发者ID:spion,项目名称:handlebars-cmd,代码行数:8,代码来源:processor.ts
示例9: loadTemplate
export function loadTemplate(name: string): Template {
const template = handlebars.compile(
fs.readFileSync(__dirname + '/../templates/' + name + '.hbs', 'utf-8')
);
return template;
}
开发者ID:evert,项目名称:a12n-server,代码行数:9,代码来源:templates.ts
示例10: function
tmpl: function(resolver, templateString, refObj, wire) {
var template = handlebars.compile(templateString);
// get the entire wire context
wire.createChild({}).
// render the template with the context
then(template).
// resolve with the rendered template
then(resolver.resolve).
catch(resolver.reject);
}
开发者ID:aerisweather,项目名称:PushButton,代码行数:11,代码来源:tmpl.ts
注:本文中的handlebars.compile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论