How to use dustjs-linkedin - 10 common examples

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 dadi / web / test / unit / view.js View on Github external
it("should return json when calling `render()`", function(done) {
    var name = "test"
    var schema = TestHelper.getPageSchema()
    schema.template = "test.dust"

    // load a template
    var template = "{#names}{title} {name}{~n}{/names}"
    var compiled = dust.compile(template, "test", true)
    dust.loadSource(compiled)

    var req = { url: "/test" }
    var p = page(name, schema)
    var v = view(req.url, p, true)

    var data = {
      title: "Sir",
      names: [{ name: "Moe" }, { name: "Larry" }, { name: "Curly" }]
    }

    v.setData(data)

    v.render(function(err, result) {
      result.should.eql(data)
      done()
    })
github epinna / tplmap / tests / env_node_tests / connect-app.js View on Github external
app.use('/blind/dust', function(req, res){
  if(req.url) {
    var url_parts = url.parse(req.url, true);

    var inj = url_parts.query.inj;
    var tpl = '';
    if('tpl' in url_parts.query && url_parts.query.tpl != '') {
      // Keep the formatting a-la-python
      tpl = url_parts.query.tpl.replace('%s', inj);
    }
    else {
      tpl = inj;
    }
    
    console.log('PAYLOAD: ' + tpl);
    dust.debugLevel = "DEBUG"
    var compiled = dust.compile(tpl, "compiled");
    dust.loadSource(compiled);
    dust.render("compiled", {}, function(err, outp) { })
    
    res.end(randomstring.generate());
  }
});
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 linkedin / dustjs-filters-secure / test / server / specRunner.js View on Github external
var jasmine = require('jasmine-node'),
    sys = require('util'),
    path = require('path'),
    o = require('../util/object'),
    dust = require('dustjs-linkedin');

/* this should be declared global in order to access them in the spec*/
GLOBAL.dust = dust;
GLOBAL.oldFilters = o.clone(dust.filters);
require('../../lib/dust-filters-secure');
GLOBAL.dustFilters = dust.filters;


for(key in jasmine) 
  global[key] = jasmine[key];

isVerbose = true;
showColors = true;
coffee = false;

process.argv.forEach(function(arg) {
  var coffee, isVerbose, showColors;
  switch (arg) {
    case '--color':
      return showColors = true;
github linkedin / dustjs-filters-secure / test / server / specRunner.js View on Github external
var jasmine = require('jasmine-node'),
    sys = require('util'),
    path = require('path'),
    o = require('../util/object'),
    dust = require('dustjs-linkedin');

/* this should be declared global in order to access them in the spec*/
GLOBAL.dust = dust;
GLOBAL.oldFilters = o.clone(dust.filters);
require('../../lib/dust-filters-secure');
GLOBAL.dustFilters = dust.filters;


for(key in jasmine) 
  global[key] = jasmine[key];

isVerbose = true;
showColors = true;
coffee = false;

process.argv.forEach(function(arg) {
  var coffee, isVerbose, showColors;
  switch (arg) {
    case '--color':
      return showColors = true;
    case '--noColor':
      return showColors = false;
github getlackey / lackey-cms / modules / core / client / js / template.js View on Github external
hashmap(engine);
list(engine);
path(engine);
is(engine);
caseSwitch(engine);
DustIntl.registerWith(engine);
youtube(engine);
dtf(engine);
log(engine);
pretty(engine);
media(engine);
split(engine);

engine.filters.base = value => base.base(basePath, value);

engine.helpers.same = (chunk, context, bodies, params) => {
    if (params.key == params.val) { //eslint-disable-line eqeqeq
        chunk.render(bodies.block, context);
    }
};

function load(name) {
    return xhr.basedGet('dust/' + name + '.js')
        .then(template => {
            // need to do that so we don't have to expose dust compile
            /*jslint evil: true */
            let loadTemplate = new Function('dust', template); //eslint-disable-line no-new-func
            /*jslint evil: false */
            loadTemplate(engine);
            return template;
        });
}
github mutualmobile / lavaca / source / src / www / js / libs / dust-helpers-1.1.0.js View on Github external
// when @eq, @lt etc are used as standalone helpers, key is required and hence check for defined
  if ( typeof params.key !== "undefined") {
    actualKey = dust.helpers.tap(params.key, chunk, context);
  }
  else if (isSelect(context)) {
    actualKey = context.current().selectKey;
    //  supports only one of the blocks in the select to be selected
    if (context.current().isResolved) {
      filterOp = function() { return false; };
    }
  }
  else {
    _console.log ("No key specified for filter in:" + filterOpType + " helper ");
    return chunk;
  }
  expectedValue = dust.helpers.tap(params.value, chunk, context);
  // coerce both the actualKey and expectedValue to the same type for equality and non-equality compares
  if (filterOp(coerce(expectedValue, params.type, context), coerce(actualKey, params.type, context))) {
    if (isSelect(context)) {
      context.current().isResolved = true;
    }
    // we want helpers without bodies to fail gracefully so check it first
    if(body) {
     return chunk.render(body, context);
    }
    else {
      _console.log( "Missing body block in the " + filterOpType + " helper ");
      return chunk;
    }
   }
   else if (bodies['else']) {
    return chunk.render(bodies['else'], context);
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);