How to use the dustjs-linkedin.render 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 lasso-js / lasso / test / dust-tests.js View on Github external
function testRender(path, data, done, options) {
    var inputPath = nodePath.join(__dirname, path);
    var expectedPath = nodePath.join(__dirname, path + '.expected.html');
    var actualPath = nodePath.join(__dirname, path + '.actual.html');
    options = options || {};
    // var compiledPath = nodePath.join(__dirname, path + '.actual.js');
    // var compiler = require('raptor-templates/compiler').createCompiler(inputPath);
    // var src = fs.readFileSync(inputPath, {encoding: 'utf8'});
    
    // var compiledSrc = compiler.compile(src);
    // fs.writeFileSync(compiledPath, compiledSrc, {encoding: 'utf8'});

    
    var dust = require('dustjs-linkedin');

    dust.render(inputPath, data, function(err, output) {
        if (err) {
            return done(err);
        }

        try {
            fs.writeFileSync(actualPath, output, {encoding: 'utf8'});

            var expected;
            try {
                expected = options.expected || fs.readFileSync(expectedPath, {encoding: 'utf8'});
            }
            catch(e) {
                expected = 'TBD';
                fs.writeFileSync(expectedPath, expected, {encoding: 'utf8'});
            }
github davglass / express-dust / lib / dust.js View on Github external
}
        baseContext = baseContext.push(res.__dynamicHelpers);
    }

    // TODO: Figure out a good way to catch parser errors. Currently Dust's
    // parser just throws them instead of passing them to the callback.
    // See https://github.com/akdubya/dustjs/issues#issue/12
    if (res.app.settings.env === 'development') {
        dust.cache = {}; // Reflect template changes without a restart.

        getView(view, function (err, content) {
            if (err) { res.req.next(err); return; }
            dust.renderSource(content, options, callback);
        });
    } else {
        dust.render(view, options, callback);
    }
};
github gitana / cloudcms-server / duster / index.js View on Github external
var executeTemplate = function(template, templatePath, context, callback)
    {
        // execute template
        var t1 = new Date().getTime();
        dust.render(template, context, function(err, out) {
            var t2 = new Date().getTime();

            if (err)
            {
                req.log("An error was caught while rendering dust template: " + templatePath + ", error: " + JSON.stringify(err, null, "  "));
            }

            // clean up - help out the garbage collector
            context.req = null;
            context.gitana = null;
            context.user = null;

            var dependencies = {
                "requires": tracker.requires,
                "produces": tracker.produces
            };
github bthorben / pdfRepo / reporter.js View on Github external
function(reportData) {
      dust.render("public_report", reportData, function(err, out) {
        if (err) {
          return console.error("Error rendering static content: " + err);
        }
        fs.writeFileSync(outputFolder + "index.html", out);
        process.exit();
      });
    });
  });
github codeactual / mainevent / app / modules / parsers.js View on Github external
var updateLogFromTemplate = function(name, log, context, callback) {
    dust.loadSource(templatesDir);
    dust.render(
      name,
      context,
      function(err, out) {
        log.preview = out;
        updatedLogs.push(log);
        callback();
      }
    );
  };
github paypal / appsforhere / lib / queue.js View on Github external
function _buildEmail(n, cb) {
    var tname = n.payload.template;
    var dustContext = new NotificationContext(n.payload.context);
    dust.render(tname, dustContext, function (err, out) {
        if (err) {
            logger.error('Failed to render notification template %s: %s - sending to dead letter.\n%s', tname, err.message, err.stack);
            q.notificationQueue.deadLetter(n);
            return;
        }
        var mailOptions = {
            from: dustContext.mailFrom,
            to: n.payload.context.email,
            subject: dustContext.mailSubject,
            text: dustContext.textMessage,
            html: dustContext.htmlMessage,
            sms: dustContext.smsMessage,
            'o:campaign': tname
        };
        cb(n, mailOptions);
    });
github darkspotinthecorner / DarkTip / src / darktip.js View on Github external
};
					var displayTempFn = function(err, content) {
						if (!elem.DarkTip.tip) {
							displayFn(err, content);
						}
					};
					style = self.style();
					if (style) {
						templateLoading = style.getWrappedLoadingTplName();
						templateIndex   = style.getWrappedIndexTplName();
					} else {
						templateLoading = self.setting('template.loading');
						templateIndex   = self.setting('template.index');
					}
					dust.render(templateLoading, newContext, displayTempFn);
					dust.render(templateIndex, newContext, displayFn);
				} else {
					elem.DarkTip.active = true;
					if (elem.DarkTip.tether) {
						elem.DarkTip.tether.enable();
					}
					if (elem.DarkTip.tip) {
						tools.element.addClass(elem.DarkTip.tip, 'darktip-active');
						elem.DarkTip.tether.position();
					}
				}
			}
			this.stop = function(elem, params) {
github dadi / web / dadi / lib / dust / index.js View on Github external
Dust.prototype.render = function (templateName, data, callback) {
  dust.render(templateName, data, callback)
}