How to use the dustjs-linkedin.renderSource function in dustjs-linkedin

To help you get started, we’ve selected a few dustjs-linkedin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newmips / newmips / structure / pieces / component / status / routes / e_status.js View on Github external
Promise.all(promisesData).then(function() {
            // Open and render dust file
            var file = fs.readFileSync(__dirname+'/../views/'+dustFile+'.dust', 'utf8');
            dust.insertLocalsFn(dustData ? dustData : {}, req);
            dust.renderSource(file, dustData || {}, function(err, rendered) {
                if (err) {
                    console.error(err);
                    return res.status(500).end();
                }

                // Send response to ajax request
                res.json({
                    content: rendered,
                    data: idSubentity || {},
                    empty: empty,
                    option: option
                });
            });
        }).catch(function(err) {
            console.error(err);
github newmips / newmips / structure / pieces / routes / data_entity.js View on Github external
Promise.all(promisesData).then(function() {
                // Open and render dust file
                var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
                dust.insertLocalsFn(dustData ? dustData : {}, req);
                dust.renderSource(file, dustData || {}, function(err, rendered) {
                    if (err) {
                        console.error(err);
                        return res.status(500).end();
                    }

                    // Send response to ajax request
                    res.json({
                        content: rendered,
                        data: idSubentity || {},
                        empty: empty,
                        option: option
                    });
                });
            }).catch(function(err) {
                console.error(err);
github newmips / newmips / structure / pieces / administration / routes / e_user.js View on Github external
Promise.all(promisesData).then(function() {
                // Open and render dust file
                var file = fs.readFileSync(__dirname + '/../views/' + dustFile + '.dust', 'utf8');
                dust.insertLocalsFn(dustData ? dustData : {}, req);
                dust.renderSource(file, dustData || {}, function(err, rendered) {
                    if (err) {
                        console.error(err);
                        return res.status(500).end();
                    }

                    // Send response to ajax request
                    res.json({
                        content: rendered,
                        data: idSubentity || {},
                        empty: empty,
                        option: option
                    });
                });
            }).catch(function(err) {
                console.error(err);
github dadi / web / test / unit / dust_helpers.js View on Github external
it('should loop through items in reverse', function (done) {
      var tmpl = '{@iter items=nums from=3 to=0 }{@markdown}{.}{/markdown}{/iter}'
      var expected = '<h1 id="3">3</h1>\n<h1 id="2">2</h1>\n<h1 id="1">1</h1>\n'

      dust.renderSource(tmpl, { nums: ['# 1', '# 2', '# 3'] }, function (err, out) {
        if (err) done(err)
        out.should.eql(expected)
        done()
      })
    })
  })
github dadi / web / test / unit / dust_helpers.js View on Github external
it('trim: should trim whitespace from specified data', function (done) {
    var source = '{@Trim data="plain text    "/}'
    var expected = 'plain text'

    dust.renderSource(source, {}, function (err, out) {
      if (err) done(err)
      out.should.eql(expected)
      done()
    })
  })
github dadi / web / test / unit / dust_helpers.js View on Github external
it('should return pluralized term', function (done) {
      var tmpl = '{@plural val="5" auto="book" /}'
      var expected = 'books'

      dust.renderSource(tmpl, {   }, function (err, out) {
        if (err) done(err)
        out.should.eql(expected)
        done()
      })
    })
github dadi / web / test / unit / dust_helpers.js View on Github external
      should.throws(function () { dust.renderSource(tmpl, { list: list, id: id  }, {}); }, Error)
github getlackey / lackey-cms / lib / mailer / index.js View on Github external
return new Promise((resolve, reject) => {
        dust.renderSource(template, vars, (err, html) => {
            if (err) {
                return reject(err);
            }
            resolve(html);
        });
    });
}
github newmips / newmips / structure / pieces / component / cra / routes / e_c_r_a.js View on Github external
}
            for (var i = 0; i &lt; activitiesById[acti].tasks.length; i++) {
                var origiTask = activitiesById[acti].tasks[i];
                for (var j = 0; j &lt; activitiesById[acti].filledTasks.length; j++) {
                    var filledTask = activitiesById[acti].filledTasks[j];
                    if (origiTask.f_date.getDate() == filledTask.f_date.getDate()) {
                        activitiesById[acti].filledTasks[j].f_duration = origiTask.f_duration;
                    }
                }
            }
            activitiesById[acti].tasks = undefined;
            activities.push(activitiesById[acti]);
        }

        var dustSrc = fs.readFileSync(__dirname+'/../views/e_c_r_a/export_template.dust', 'utf8');
        dust.renderSource(dustSrc, {
            activities: activities,
            daysAndLabels: daysAndLabels,
            workedDays: workedDays,
            cra: cra
        }, function(err, html) {
            if (err)
                return error500(err, req, res);

            var fileName = __dirname+'/../views/e_c_r_a/'+cra.id+'_cra_'+cra.f_year+'_'+cra.f_month+'.pdf';
            pdf.create(html, {orientation: 'landscape'}).toFile(fileName, function(err, data) {
                if (err)
                    return error500(err, req, res);
                fs.readFile(fileName, function(err, data) {
                    if (err)
                        return error500(err, req, res);
                    res.writeHead(200, {"Content-Type": "application/pdf"});