(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);
				}
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);
}
 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");
 });
Beispiel #4
0
 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 */  
Beispiel #5
0
 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
         });
       }
     });
   }
 });
Beispiel #6
0
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);
}
Beispiel #7
0
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
}
 const result = _.mapValues(template, (t) => {
   try {
     return Mustache.render(t, data);
   } catch (e) {
     log.error('Could not apply data to template', e);
     error = e;
   }
 });
Beispiel #9
0
 storage.get('templates', function(error, templates) {
   if (error) {
     console.error(error);
   } else {
     let rendered = Mustache.render(template, {templates: templates});
     $('.content').html(rendered);
   }
 });
Beispiel #10
0
 it("should work with Proxy", () => {
     const v = { foo: "bar" };
     
     const v_ = new Proxy(v, {
         get(that, expr) { return that[expr].toUpperCase(); }
     });      
     const r = mustache.render("Foo {{v_.foo}}", { v_ });
     assert.equal(r, "Foo BAR");
 });