本文整理汇总了TypeScript中handlebars.registerPartial函数的典型用法代码示例。如果您正苦于以下问题:TypeScript registerPartial函数的具体用法?TypeScript registerPartial怎么用?TypeScript registerPartial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了registerPartial函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(commitMessages: string[]) {
super();
this.commitMessages = commitMessages;
handlebars.registerPartial('workitem', WorkItemTemplateBase);
this.jenkinsClient = new JenkinsRestClient();
}
示例2: registerPartials
function registerPartials(partialsGlob: string) {
const partialTemplateFileNames = globSync(partialsGlob);
logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
for (const partialTemplateFileName of partialTemplateFileNames) {
const namedContent = utils.getNamedContent(partialTemplateFileName);
Handlebars.registerPartial(namedContent.name, namedContent.content);
}
return partialsGlob;
}
示例3: buildWebAppHtml
function buildWebAppHtml() {
process.stdout.write("buliding web app index...\n");
// build cache busted file name maps
const cacheMap: any = {};
cacheMap.stylesheets = getCacheMapping("stylesheets");
cacheMap.scripts = getCacheMapping("scripts");
// get the content for the critical css
const encoding = "utf-8";
const loadingCss = FileSystem.readFileSync("./public/dist/styles/" + cacheMap.stylesheets.loading, encoding);
Handlebars.registerPartial("loading.css", loadingCss);
// get the template index page
const file = FileSystem.readFileSync("./public/src/index.html", encoding);
const template = Handlebars.compile(file);
// apply the cache busted file names and contents to the index page
FileSystem.writeFileSync("./public/dist/index.html", template(cacheMap));
process.stdout.write("web app index built\n");
}
示例4: constructor
constructor() {
super();
handlebars.registerPartial('commit', CommitTemplateBase);
this.jenkinsClient = new JenkinsRestClient();
}
示例5: template3
const template3 = Handlebars.compile<typeof context3>(source3);
template3(context3);
const source4 = '<ul>{{#people}}<li>{{#link}}{{name}}{{/link}}</li>{{/people}}</ul>';
Handlebars.registerHelper('link', function(context: any) {
return '<a href="/people/' + this.id + '">' + context.fn(this) + '</a>';
});
const template4 = Handlebars.compile<{ people: { name: string, id: number }[] }>(source4);
const data2 = { 'people': [
{ 'name': 'Alan', 'id': 1 },
{ 'name': 'Yehuda', 'id': 2 }
]};
template4(data2);
const source5 = '<ul>{{#people}}<li>{{> link}}</li>{{/people}}</ul>';
Handlebars.registerPartial('link', '<a href="/people/{{id}}">{{name}}</a>');
const template5 = Handlebars.compile(source5);
const data3 = { 'people': [
{ 'name': 'Alan', 'id': 1 },
{ 'name': 'Yehuda', 'id': 2 }
]};
template5(data3);
const source6 = '{{#list nav}}<a href="{{url}}">{{title}}</a>{{/list}}';
const template6 = Handlebars.compile(source6);
Handlebars.registerHelper('list', (context, options: Handlebars.HelperOptions) => {
let ret = "<ul>";
for(let i=0, j=context.length; i<j; i++) {
ret = ret + "<li>" + options.fn(context[i]) + "</li>";
}
return ret + "</ul>";
示例6:
urlText: Handlebars.compile($('#tmpl-urltext').html()),
detail: Handlebars.compile($('#tmpl-detail').html()),
credentialForm: Handlebars.compile($('#tmpl-credentialform').html()),
deleteConfirmationDialog: Handlebars.compile($('#tmpl-deleteconfirmationdialog').html()),
optionsDialog: Handlebars.compile($('#tmpl-optionsdialog').html()),
exportedDataWindow: Handlebars.compile($('#tmpl-exporteddatawindow').html()),
credentialTable: Handlebars.compile($('#tmpl-credentialtable').html()),
credentialTableRow: Handlebars.compile($('#tmpl-credentialtablerow').html()),
validationMessage: Handlebars.compile($('#tmpl-validationmessage').html()),
modalHeader: Handlebars.compile($('#tmpl-modalheader').html()),
modalBody: Handlebars.compile($('#tmpl-modalbody').html()),
modalFooter: Handlebars.compile($('#tmpl-modalfooter').html()),
copyLink: Handlebars.compile($('#tmpl-copylink').html())
};
Handlebars.registerPartial('credentialtablerow', templates.credentialTableRow);
Handlebars.registerPartial('copylink', templates.copyLink);
Handlebars.registerHelper('breaklines', (text: string) => {
const escapedText = Handlebars.Utils.escapeExpression(text);
return new Handlebars.SafeString(escapedText.replace(/(\r\n|\n|\r)/gm, '<br />'));
});
Handlebars.registerHelper('truncate', (text: string, size: number) => {
const escapedText = Handlebars.Utils.escapeExpression(truncate(text, size));
return new Handlebars.SafeString(escapedText);
});
let currentSession: any = null;