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

TypeScript mustache.render函数代码示例

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

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



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

示例1: Buffer

				(issue: any, updateImpedimentsFileComplete: Function) => {
					var input = new Buffer(impediments.content, "base64").toString("utf8");
					var definition= this.parseImpediments(input);

					var data: any = definition.issues.filter((x: any) => { return x.number == requestBody.number });

					if (data.length > 0) {
						data = data[0];
					} else {
						data = issue;
						issue.impediments = [];
						definition.issues.push(issue);
					}

					data.impediments.push({
						date: moment().format(configuration.dateFormat),
						comment: requestBody.body
					});

					self.logger.debug(definition);
					
					var newContent = mustache.render(template, definition);

					self.logger.debug(newContent);

					requestBody.message = "Updated impediments";
					requestBody.sha = impediments.sha;
					requestBody.content = new Buffer(newContent, 'utf8').toString("base64");

					self.logInfo([user, repository, number], "Uploading new impediments file");

					self.getGitHubClient().repos.updateFile(requestBody, updateImpedimentsFileComplete);
				}
开发者ID:ciuliot,项目名称:github-tracker,代码行数:33,代码来源:impedimentsController.ts


示例2: replaceBetween

function replaceBetween(readmeContents: string, section: string, settings: IGulpSettings): string {
    const fs = require("fs");
    const os = require("os");

    const starter = `<!-- {{${section}}} -->`;
    const ender = `<!-- {{/${section}}} -->`;

    const start = readmeContents.indexOf(starter) + starter.length;
    const end = readmeContents.indexOf(ender);
    const addingWeb: boolean = !!settings.packageSchema.shenanigans.web;

    return [
        readmeContents.substring(0, start),
        mustache.render(
            fs.readFileSync(`./node_modules/gulp-shenanigans/src/setup/readme/${section}.md`).toString().trim(),
            {
                ...settings,
                buildCommands: addingWeb
                    ? ["gulp setup", "gulp"]
                    : ["gulp"],
                extra: addingWeb
                    ? "After setting up and building locally, open `src/index.html` to launch."
                    : ""
            }),
        readmeContents.substring(end)
    ].join(os.EOL);
}
开发者ID:FullScreenShenanigans,项目名称:gulp-shenanigans,代码行数:27,代码来源:readme.ts


示例3: it

 it("should work with v_display", () => {
     const v = { sn: "bar", givenName: "bar2" } as v;
     
     const v_ = v_display(v, { sn: { oneOf: [ { const: "bar", title: "BAR"} ] } })
     const r = mustache.render("Foo {{v_display.sn}} {{v_display.givenName}}", { v_display: v_ });
     assert.equal(r, "Foo BAR bar2");
 });
开发者ID:prigaux,项目名称:compte-externe,代码行数:7,代码来源:mustache.test.ts


示例4: getNestedProperty

 mongo.find(collection, JSON.parse(query), (error, data) => {
   if (error) {
     console.error('query failed');
     return;
   } else {
     for (let i=0; i<data.length; i++) {
       let email = getNestedProperty(data[i], email_fields),
           name = getNestedProperty(data[i], name_fields);
       let request = {
         from: from_email,
         to: email,
         subject: subject,
         text: content,
         html: Mustache.render(html, {name: name})
       };
       mailer.messages().send(request, function(error, body) {
         if (error) {
           console.error(error);
         } else {
           console.log(body);
         }
       });
     } /* END FOR */
   }
 }); /* END MONGO FIND */  
开发者ID:hack-rpi,项目名称:Email-Board,代码行数:25,代码来源:email.ts


示例5: function

 fs.readFile(__dirname + '/../templates/email.mst', 'utf-8', (error, template) => {
   if (error) {
     console.error(error);
   } else {
     tmp_files.push(tmpobj);
     let rendered = Mustache.render(template, {email: tmpobj.name});
     $('.content').html(rendered);
     storage.get('queries', function(error, queries) {
       if (error) {
         console.error(error);
       } else {
         let hound = new Bloodhound({
           datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
           queryTokenizer: Bloodhound.tokenizers.whitespace,
           identify: (q) => { return q.name; },
           local: queries
         });
         $('input[name="query"]').typeahead({
           hint: true,
           minLength: 0,
           highlight: true
         }, {
           name: 'queries',
           display: 'name',
           source: hound
         });
       }
     });
   }
 });
开发者ID:hack-rpi,项目名称:Email-Board,代码行数:30,代码来源:email.ts


示例6: generate

export function generate(viewModel?:IDataStore, config?:ReporterConfig):void {
    var opts = {encoding: 'utf8'};

    if (viewModel == null && config == null) {
        config             = new ReporterConfig();
        var strData:string = fs.readFileSync(config.viewDataPath, opts);
        viewModel          = JSON.parse(strData);
        console.log('----> Using default config & data to test report: \n', config);
    }

    // First lets load up all the templates
    var headerStr  = fs.readFileSync(config.headerTemplatePath, opts);
    var indexStr   = fs.readFileSync(config.indexTemplatePath, opts);
    var suiteStr   = fs.readFileSync(config.suiteTemplatePath, opts);
    var titleStr   = fs.readFileSync(config.titleTemplatePath, opts);
    var summaryStr = fs.readFileSync(config.summaryTemplatePath, opts);
    var latestStr  = fs.readFileSync(config.latestTemplatePath, opts);

    // Lets convert the scss into CSS
    var stylesStr = sass.renderSync({
        file       : config.stylesPath,
        outputStyle: 'expanded',
        indentWidth: 4
    }).css.toString();

    // Now lets build up the templates to pass
    var partials = {header: headerStr, title: titleStr, suite: suiteStr, summary: summaryStr};

    // Now the model
    _.extend(viewModel, {
        styles: stylesStr,
        title : config.reportName,
        env   : process.env
    });

    // Render with mustache
    var reportResult = mustache.render(indexStr, viewModel, partials);
    var latestResult = mustache.render(latestStr, {latestReportName: config.latestReportName});

    // Write out the report
    if (!fs.existsSync(config.reportDir)) {
        fs.mkdirSync(config.reportDir);
    }
    if (config.reportDynamicPath) fs.writeFileSync(config.reportDynamicPath, reportResult, opts);
    fs.writeFileSync(config.reportStaticPath, reportResult, opts);
    fs.writeFileSync(config.reportDir + '/latest.html', latestResult, opts);
}
开发者ID:PepkorIT,项目名称:beach-day,代码行数:47,代码来源:ReportGenerator.ts


示例7: renderTemplate

export function renderTemplate(template: string, context: any): string {
  let i = 0
  while (i < MAX_NESTING_LEVEL && containsTemplate(template)) {
    template = Mustache.render(template, context)
    i++
  }
  return template
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:8,代码来源:templating.ts


示例8: catch

 const result = _.mapValues(template, (t) => {
   try {
     return Mustache.render(t, data);
   } catch (e) {
     log.error('Could not apply data to template', e);
     error = e;
   }
 });
开发者ID:bitpay,项目名称:bitcore,代码行数:8,代码来源:pushnotificationsservice.ts


示例9: function

 storage.get('templates', function(error, templates) {
   if (error) {
     console.error(error);
   } else {
     let rendered = Mustache.render(template, {templates: templates});
     $('.content').html(rendered);
   }
 });
开发者ID:hack-rpi,项目名称:Email-Board,代码行数:8,代码来源:main.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript mysql.createConnection函数代码示例发布时间:2022-05-25
下一篇:
TypeScript multiparty.Form类代码示例发布时间: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