当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript handlebars.registerPartial函数代码示例

本文整理汇总了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();
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:8,代码来源:WorkItemsDownloader.ts

示例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;
}
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:9,代码来源:index.ts

示例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");
}
开发者ID:alsatian-test,项目名称:alsatian-website,代码行数:24,代码来源:build-html.ts

示例4: constructor

    constructor() {
        super();

        handlebars.registerPartial('commit', CommitTemplateBase);
        this.jenkinsClient = new JenkinsRestClient();
    }
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:6,代码来源:CommitsDownloader.ts

示例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>";
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:handlebars-tests.ts

示例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;
开发者ID:markashleybell,项目名称:vault,代码行数:30,代码来源:index.ts


注:本文中的handlebars.registerPartial函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。