當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。