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


TypeScript mustache.render函数代码示例

本文整理汇总了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;未经允许,请勿转载。