How to use the dustjs-linkedin.filters 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 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
engine.helpers = helpers.helpers;
iterate(engine);
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 newmips / newmips / server.js View on Github external
res.locals.M_ = function(ch, con, bo, params) {
        return ch.write(language(lang).M_(params.key, params.params));
    };

    res.locals.isAdmin = function(chunk, context, bodies, params) {
        if(req.isAuthenticated() && req.session.passport && req.session.passport.user.id_role == 1)
            return true;
        return false;
    };

    res.locals.user_lang = lang;
    res.locals.globalConf = globalConf;

    // Filters
    dust.filters.stringify = function(value) {
        return JSON.stringify(value);
    };

    next();
});
github davglass / express-dust / lib / dust.js View on Github external
fsPath = require('path'),
    http   = require('http'),

    dust = require('dustjs-linkedin'),

    baseContext = dust.makeBase({});

var mix = function(s, d) {
    for (var i in s) {
        d[i] = s[i]
    }
    return d;
}

module.exports = {
    filters : dust.filters
  , makeBase: function(obj) {
        baseContext = dust.makeBase(mix(baseContext.global, obj));
        return baseContext;
    }
}


// Loads the named template the first time it's used (it will be cached for
// later calls).
function getView(name, callback) {
    name = name.replace(/\.dust$/, '') + '.dust';
    fs.readFile(fsPath.join(process.cwd(), 'views', name), 'utf8', callback);
}

dust.onLoad = getView;
github DecentCMS / DecentCMS / modules / core / ui / services / dust-view-engine.js View on Github external
dust.filters.dump = function dumpDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return pretty(filteredValue, 2, 'HTML');
  }

  dust.filters.log = function logDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return '';
  }

  dust.filters.plain = function plainDustFilter(html) {
    return striptags(html).replace(/\s\s+/gm, ' ').replace(/[\r\n]/gm, ' ').trim();
  }

  dust.filters.firstp = html => summarize(html);

  /**
   * @description
   * Loads the rendering function from the provided path.
   * @param {string} templatePath The path to the .dust file.
   * @param {Function} done The callback function to call when the template is loaded.
   * @returns {function} The template function.
   */
  this.load = function loadCodeTemplate(templatePath, done) {
    var fs = require('fs');
    if (dust.cache.hasOwnProperty(templatePath)) {
      return done(getDustTemplate(templatePath));
    }
    fs.readFile(templatePath, function readTemplate(err, template) {
      dust.register(
        templatePath,
github DecentCMS / DecentCMS / modules / core / ui / services / dust-view-engine.js View on Github external
if (!val) return chunk;
    var dt = (val.constructor === Date ? DateTime.fromJSDate(val) : DateTime.fromISO(val))
      .setLocale(locale);
    if (!dt.isValid) {
      dt = DateTime.fromJSDate(new Date(val));
    }
    var format = dust.helpers.tap(params.format, chunk, context) || DateTime.DATETIME_SHORT;
    return chunk.write(dt.toFormat(format));
  }

  dust.filters.dump = function dumpDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return pretty(filteredValue, 2, 'HTML');
  }

  dust.filters.log = function logDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return '';
  }

  dust.filters.plain = function plainDustFilter(html) {
    return striptags(html).replace(/\s\s+/gm, ' ').replace(/[\r\n]/gm, ' ').trim();
  }

  dust.filters.firstp = html => summarize(html);

  /**
   * @description
   * Loads the rendering function from the provided path.
   * @param {string} templatePath The path to the .dust file.
   * @param {Function} done The callback function to call when the template is loaded.
   * @returns {function} The template function.
github DecentCMS / DecentCMS / modules / core / ui / services / dust-view-engine.js View on Github external
dust.helpers.date = function dateDustHelper(chunk, context, bodies, params) {
    var renderer = chunk.root['decent-renderer'];
    var scope = renderer.scope;
    var locale = scope.require('shell').settings.locale || 'en-US';
    var val = dust.helpers.tap(params.value, chunk, context);
    if (!val) return chunk;
    var dt = (val.constructor === Date ? DateTime.fromJSDate(val) : DateTime.fromISO(val))
      .setLocale(locale);
    if (!dt.isValid) {
      dt = DateTime.fromJSDate(new Date(val));
    }
    var format = dust.helpers.tap(params.format, chunk, context) || DateTime.DATETIME_SHORT;
    return chunk.write(dt.toFormat(format));
  }

  dust.filters.dump = function dumpDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return pretty(filteredValue, 2, 'HTML');
  }

  dust.filters.log = function logDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return '';
  }

  dust.filters.plain = function plainDustFilter(html) {
    return striptags(html).replace(/\s\s+/gm, ' ').replace(/[\r\n]/gm, ' ').trim();
  }

  dust.filters.firstp = html => summarize(html);

  /**
github DecentCMS / DecentCMS / modules / core / ui / services / dust-view-engine.js View on Github external
}
    var format = dust.helpers.tap(params.format, chunk, context) || DateTime.DATETIME_SHORT;
    return chunk.write(dt.toFormat(format));
  }

  dust.filters.dump = function dumpDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return pretty(filteredValue, 2, 'HTML');
  }

  dust.filters.log = function logDustFilter(value) {
    var filteredValue = shapeHelper.copy(value);
    return '';
  }

  dust.filters.plain = function plainDustFilter(html) {
    return striptags(html).replace(/\s\s+/gm, ' ').replace(/[\r\n]/gm, ' ').trim();
  }

  dust.filters.firstp = html => summarize(html);

  /**
   * @description
   * Loads the rendering function from the provided path.
   * @param {string} templatePath The path to the .dust file.
   * @param {Function} done The callback function to call when the template is loaded.
   * @returns {function} The template function.
   */
  this.load = function loadCodeTemplate(templatePath, done) {
    var fs = require('fs');
    if (dust.cache.hasOwnProperty(templatePath)) {
      return done(getDustTemplate(templatePath));