• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript handlebars.registerHelper函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中handlebars.registerHelper函数的典型用法代码示例。如果您正苦于以下问题:TypeScript registerHelper函数的具体用法?TypeScript registerHelper怎么用?TypeScript registerHelper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了registerHelper函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 /**
 * Create a new MarkdownTheme instance.
 *
 * @param renderer  The renderer this theme is attached to.
 * @param basePath  The base path of this theme.
 */
 constructor(renderer: td.output.Renderer, basePath: string) {
   super(renderer, basePath);
   renderer.removePlugin('assets'); // markdown doesn't need assets
   renderer.removePlugin('javascriptIndex'); // markdown doesn't need search.js
   renderer.removePlugin('prettyPrint'); // new lines and spaces have meaning in markdown, don't omit them automatically!
   Handlebars.registerHelper('newLine', () => '\n');
 }
开发者ID:doktordirk,项目名称:typedoc-markdown-theme,代码行数:13,代码来源:theme.ts


示例2: GetBuildIdIndex

    private GetBuildIdIndex(jenkinsJobDetails: JenkinsJobDetails, startBuildId: number, endBuildId: number): Q.Promise<any> {
        let defer = Q.defer<any>();
        let buildUrl: string = `${jenkinsJobDetails.multiBranchPipelineUrlInfix}/api/json?tree=allBuilds[number]`;
        let startIndex: number = -1;
        let endIndex: number = -1;

        console.log(tl.loc("FindBuildIndex"));
        handlebars.registerHelper('BuildIndex', function(buildId, index, options) {
            if (buildId == startBuildId) {
                startIndex = index;
            } else if (buildId == endBuildId) {
                endIndex = index;
            }

            return options.fn(this);
        });

        let source: string = '{{#each allBuilds}}{{#BuildIndex this.number @index}}{{/BuildIndex}}{{/each}}';
        let downloadHelper: JenkinsRestClient = new JenkinsRestClient();
        downloadHelper.DownloadJsonContent(buildUrl, source, null).then(() => {
            console.log(tl.loc("FoundBuildIndex", startIndex, endIndex));
            if (startIndex === -1 || endIndex === -1) {
                tl.debug(`cannot find valid startIndex ${startIndex} or endIndex ${endIndex}`);
                defer.reject(tl.loc("CannotFindBuilds"));
            }
            else {
                defer.resolve({startIndex: startIndex, endIndex: endIndex});
            }
        }, (error) => {
            defer.reject(error);
        });

        return defer.promise;
    }
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:34,代码来源:ArtifactDetailsDownloader.ts


示例3: generateServiceDefinitions

  generateServiceDefinitions(api: meta.ServiceInfo) {
    var moduleTemplate = this.fetchTemplate("module")

    this.cleanShapes(api.descriptor);

    handlebars.registerHelper("camelCase", function(name: string) {
      return name.charAt(0).toLowerCase() + name.substring(1)
    })

    return moduleTemplate(api)
  }
开发者ID:Bnaya,项目名称:aws-sdk-typescript,代码行数:11,代码来源:generator.ts


示例4: registerHandlebarHelpers

    private registerHandlebarHelpers() {
        Handlebars.registerHelper({
            crmdata: (pbiType: string, group: PbiService.GroupModel = null, dashboard: PbiService.DashboardModel = null, opt: any) => {
                // Note: Need to take get this and arguments using eval as the TS compiler override their values in this callback and thus can't be referenced directly.
                // tslint:disable:no-eval
                let that = eval("this");
                let args = eval("arguments");
                // tslint:enable:no-eval
                return this.getCrmDataQueryForItem(
                    pbiType,
                    that,
                    (args.length > 2 ? group : null),    // Handlebars append opt at the end - thus num args vary
                    (args.length > 3 ? dashboard : null) // Handlebars append opt at the end - thus num args vary
                );
            },

            previewquery: (pbiType: string, group: PbiService.GroupModel = null, dashboard: PbiService.DashboardModel = null, opt: any) => {
                // Note: Need to take get this and arguments using eval as the TS compiler override their values in this callback and thus can't be referenced directly.
                // tslint:disable:no-eval
                let that = eval("this");
                let args = eval("arguments");
                // tslint:enable:no-eval
                let crmData = this.getCrmDataQueryForItem(
                    pbiType,
                    that,
                    (args.length > 2 ? group : null),    // Handlebars append opt at the end - thus num args vary
                    (args.length > 3 ? dashboard : null) // Handlebars append opt at the end - thus num args vary
                );

                if (pbiType.toLowerCase() === "report") {
                    crmData += "&customFn=PbiPreviewLogVisualsFn";
                }

                return `data=${encodeURIComponent(crmData)}`;
            }
        });
    }
开发者ID:taarskog,项目名称:crm-powerbi-viewer,代码行数:37,代码来源:admin.ts


示例5:

 _.each(helpers, (val, key) => {
   Handlebars.registerHelper(key, val);
 });
开发者ID:do5,项目名称:mcgen,代码行数:3,代码来源:code-builder.ts


示例6: function

//import Handlebars = require('handlebars');
import * as Handlebars from 'handlebars';

const context = {
    author: { firstName: 'Alan', lastName: 'Johnson' },
    body: 'I Love Handlebars',
    comments: [{
        author: { firstName: 'Yehuda', lastName: 'Katz' },
        body: 'Me too!'
    }]
};
Handlebars.registerHelper('fullName', (person: typeof context.author) => {
    return person.firstName + ' ' + person.lastName;
});

Handlebars.registerHelper('agree_button', function() {
    return new Handlebars.SafeString(
      '<button>I agree. I ' + this.emotion + ' ' + this.name + '</button>'
    );
});

const source1 = '<p>Hello, my name is {{name}}. I am from {{hometown}}. I have ' +
             '{{kids.length}} kids:</p>' +
             '<ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul>';
const template1 = Handlebars.compile(source1);
template1({ name: "Alan", hometown: "Somewhere, TX", kids: [{name: "Jimmy", age: 12}, {name: "Sally", age: 4}]});

Handlebars.registerHelper('link_to', (context: typeof post) => {
    return '<a href="' + context.url + '">' + context.body + '</a>';
});
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:30,代码来源:handlebars-tests.ts


示例7: function

 * Usage:
 *
 *     {{include 'filename.tpl.md' context=obj noeval=true}}
 *
 * Includes another file. You can optionally pass a context named parameter to change the context.
 * The file will receive the data from the context as variables.
 *
 * The noeval argument will disable evaluation of the file as a handlebars template - it will be
 * included verbatim.
 *
 */
hbs.registerHelper('include', function(this: any, file, opts: hbs.HelperOptions) {
  let ctx = null == opts.hash['context'] ? this : opts.hash['context'];
  let noeval = null != opts.hash['noeval'];
  let target = path.resolve(wd, file);
  let oldwd = wd;
  wd = path.dirname(target);
  let res = noeval ? fs.readFileSync(target) : subHandle(target, ctx);
  wd = oldwd;
  return res;
});

/**
 * ## filetree
 *
 * Usage:
 *
 *     {{filetree relativePath padding}}
 *
 * * relativePath - the path of the directory relative to current file
 * * padding - how much to pad each item in the tree except the first one
 *
开发者ID:spion,项目名称:handlebars-cmd,代码行数:32,代码来源:processor.ts


示例8: function

///<reference path="../typings/globals/handlebars/index.d.ts" />

import * as Handlebars from "handlebars";

Handlebars.registerHelper(
	'selectOptions',
	function(options: Array<any>|{[k:string]:any}, selected:any, dflt:{v:any, k:string}){
		let r: string;
		let i: any;
		let f: (k:string, v:any, s:boolean) => string;
		f = (k,v,s) => '<option value="'+k+'"'+(s?' selected':'')+'>'+v+'</option>';
		r = dflt ? f(dflt.k,dflt.v,false) : '';
		if (options instanceof Array) {
			let l: number = options.length;
			for (i=0; i<l; i++){r += f(i,options[i],i===selected);}
		} else {
			for (i in options) {r += f(i,options[i],i===selected);}
		}
		return r;
	}
);
Handlebars.registerHelper(
	'radioOptions',
	function(name:string, options:any[]|{[k:string]:any}, selected:any){
		let r: string;
		let i: any;
		let f: (n:string, k:string, v:any, s:boolean) => string;
		f = (n,k,v,s) => '<label><input type="radio" name="'+n+'" value="'+k+'"'+(s?' checked':'')+' /> '+v+'</label>';
		r = '';
		if (options instanceof Array) {
			let l: number = options.length;
开发者ID:hanzo2001,项目名称:gi-json,代码行数:31,代码来源:hb-helpers.ts


示例9: function

"use strict";

import * as Handlebars from 'handlebars';
import * as path from 'path';
import * as url from 'url';
import * as btoa from 'btoa';
import * as atob from 'atob';
import * as pretty from 'pretty';

import {IRenderer, IRendererOptions} from './Renderer';
import {Component} from './Component';

Handlebars.registerHelper("pp", function(object:{}){
  return new Handlebars.SafeString(JSON.stringify(object));
});

Handlebars.registerHelper("beautified", function(object:{}){
  return pretty(object);
});

Handlebars.registerHelper("eq", function(a: {}, b: {}){
  return a === b;
});

Handlebars.registerHelper("rellink", function(link, options){
  var absoluteLinkPath = link;
  var uri = url.parse(link);
  var options =  options.data.root, cwd, root;

  if (uri.host !== null) {
    // we have an URL here, not a path, so just return it
开发者ID:janpersiel,项目名称:stylegen,代码行数:31,代码来源:HandlebarsRenderer.ts


示例10: function

import * as Handlebars from "handlebars";
import * as request from 'request';
import * as util from 'util';

import { readFile, writeFile } from "./lib/utility/fs";

import { execSync } from "child_process";

Handlebars.registerHelper('bash', function (command: string) {
    return execSync(command).toString().replace(/\[\d{1,2}m/gi, '')
})

async function fromGithub (endpoint: string) {
    return util.promisify(request)({
            method: 'GET',
            url: 'https://api.github.com/' + endpoint,
            json: true,
            headers: { 'User-Agent': 'README generator' }
        }).then(response => response.body)
}

Promise
    .all([
        readFile('./README.handlebars', 'utf8'),
        fromGithub('repos/2fd/graphdoc'),
        fromGithub('repos/2fd/graphdoc/contributors').then(contributors => contributors.filter(c => c.login !== '2fd') ),
    ])
    .then(([template, project, contributors]) => {
        return writeFile('README.md',  Handlebars.compile(template)({project, contributors}))
    })
开发者ID:2fd,项目名称:graphdoc,代码行数:30,代码来源:README.ts


示例11: isChecked

    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;

// Pure functions

export function isChecked(el: JQuery) {
    return (el[0] as HTMLInputElement).checked;
}
开发者ID:markashleybell,项目名称:vault,代码行数:31,代码来源:index.ts


示例12: constructor

 constructor(renderer: Renderer, basePath) {
     super(renderer, basePath);
     Handlebars.registerHelper('getConfigData', this.getConfigData);
 }
开发者ID:IgniteUI,项目名称:igniteui-angular,代码行数:4,代码来源:theme.ts


示例13: registerHelpers_

export function registerHelpers_() {
    handlebars.registerHelper('date', date => {
        return getDuration(date)
    })

    handlebars.registerHelper('compareLink', function() {
        const { github_host, user, repo, pullHeadSHA, currentSHA } = this.options

        return `${github_host}${user}/${repo}/compare/${pullHeadSHA}...${currentSHA}`
    })

    handlebars.registerHelper('forwardedLink', function() {
        const { github_host, fwd, repo, forwardedPull } = this.options

        return `${github_host}${fwd}/${repo}/pull/${forwardedPull}`
    })

    handlebars.registerHelper('link', function() {
        const { github_host, user, repo, number } = this.options

        return `${github_host}${user}/${repo}/pull/${number}`
    })

    handlebars.registerHelper('submittedLink', function() {
        const { github_host, submit, repo, submittedPull } = this.options

        return `${github_host}${submit}/${repo}/pull/${submittedPull}`
    })

    handlebars.registerHelper('issueLink', function() {
        const { github_host, user, repo, number } = this.options

        return `${github_host}${user}/${repo}/issues/${number}`
    })

    handlebars.registerHelper('gistLink', function() {
        const { github_gist_host, loggedUser, id } = this.options

        return `${github_gist_host}${loggedUser}/${id}`
    })

    handlebars.registerHelper('repoLink', function() {
        const { github_gist_host, user, repo } = this.options

        return `${github_gist_host}${user}/${repo}`
    })

    handlebars.registerHelper('wordwrap', (text, padding, stripNewLines) => {
        let gutter = ''

        if (stripNewLines !== false) {
            text = text.replace(/[\r\n\s\t]+/g, ' ')
        }

        text = wrap(text).split('\n')

        if (padding > 0) {
            gutter = ' '.repeat(padding)
        }

        return text.join(`\n${gutter}`)
    })
}
开发者ID:gamerson,项目名称:gh,代码行数:63,代码来源:logger.ts


示例14: registerHelper

export function registerHelper(name, callback) {
    handlebars.registerHelper(name, callback)
}
开发者ID:gamerson,项目名称:gh,代码行数:3,代码来源:logger.ts


示例15: function

import Handlebars from "handlebars";
import { ABIDefinition } from "web3/eth/abi";

Handlebars.registerHelper("capitalize", (word: string) => {
  return word.charAt(0).toUpperCase() + word.slice(1);
});

Handlebars.registerHelper("lowercase", (word: string) => {
  return word.toLowerCase();
});

Handlebars.registerHelper("ifview", function(stateMutability: string, options: Handlebars.HelperOptions) {
  const isView = stateMutability === "view" || stateMutability === "pure" || stateMutability === "constant";
  if (isView) {
    return options.fn(this);
  }
  return options.inverse(this);
});

Handlebars.registerHelper("ifstring", function(value: string, options: Handlebars.HelperOptions) {
  if (value === "string") {
    return options.fn(this);
  }
  return options.inverse(this);
});

Handlebars.registerHelper("ifeq", function(elem: string, value: string, options: Handlebars.HelperOptions) {
  if (elem === value) {
    return options.fn(this);
  }
  return options.inverse(this);
开发者ID:iurimatias,项目名称:embark-framework,代码行数:31,代码来源:handlebarHelpers.ts


示例16: writeOutputFile

        Handlebars.registerPartial(namedContent.name, namedContent.content);
    }
    return partialsGlob;
}

function writeOutputFile(name: string, renderedTsCode: string): void {
    let fileName = toSnakeCase(name);
    if (fileName === 'z_r_x_token') {
        fileName = 'zrx_token';
    }
    const filePath = `${args.output}/${fileName}.ts`;
    fs.writeFileSync(filePath, renderedTsCode);
    logUtils.log(`Created: ${chalk.bold(filePath)}`);
}

Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend));
Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend));

if (args.partials) {
    registerPartials(args.partials);
}
const mainTemplate = utils.getNamedContent(args.template);
const template = Handlebars.compile<ContextData>(mainTemplate.content);
const abiFileNames = globSync(args.abis);

if (_.isEmpty(abiFileNames)) {
    logUtils.log(`${chalk.red(`No ABI files found.`)}`);
    logUtils.log(`Please make sure you've passed the correct folder name and that the files have
               ${chalk.bold('*.json')} extensions`);
    process.exit(1);
} else {
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:index.ts


示例17: function

import * as Handlebars from 'handlebars';
import utils from 'lib/utils';

Handlebars.registerHelper('url', function(routeName: String) {
  var params = [].slice.call(arguments, 1);
  var options = params.pop();
  return utils.reverse(routeName, params);
});
开发者ID:fafnirical,项目名称:test--chaplin,代码行数:8,代码来源:view-helper.ts


示例18: function

import * as Handlebars from 'handlebars';
import { SchemaHelper } from "@maxxton/microdocs-core/helpers/schema/schema.helper";
import { Schema } from "@maxxton/microdocs-core/domain";

Handlebars.registerHelper( 'toUpperCase', function ( str:string ) {
  return str.toUpperCase();
} );
Handlebars.registerHelper( 'ifEq', function ( v1:any, v2:any, options:any ) {
  if ( v1 === v2 ) {
    return options.fn( this );
  }
  return options.inverse( this );
} );
Handlebars.registerHelper( 'ifEq', function ( v1:any, v2:any, options:any ) {
  if ( v1 === v2 ) {
    return options.fn( this );
  }
  return options.inverse( this );
} );
Handlebars.registerHelper( 'ifNotEmpty', function ( v1:any, options:any ) {
  if ( v1 ) {
    if ( typeof(v1) === 'string' ) {
      if ( v1.length > 0 ) {
        return options.fn( this );
      }
    } else if ( Array.isArray( v1 ) ) {
      if ( v1.length > 0 ) {
        return options.fn( this );
      }
    } else if ( typeof(v1) === 'object' ) {
开发者ID:MaxxtonGroup,项目名称:microdocs,代码行数:30,代码来源:handlebars-functions.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript handlebars.registerPartial函数代码示例发布时间:2022-05-25
下一篇:
TypeScript handlebars.compile函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap