How to use the dustjs-linkedin.optimizers 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 unstoppablecarl / js-roguelike-skeleton / manual-src / task.js View on Github external
var util = require('util');
var inspect = function(obj){
    console.log(util.inspect(obj, {
        depth: null,
        showHidden: true,
        colors: true
    }));
};
        // Force task into async mode and grab a handle to the "done" function.
        var done = this.async();

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

        // disable whitespace removal
        dust.optimizers.format = function(ctx, node) { return node };

        var metalsmith = require('metalsmith');
        var markDown = require('metalsmith-markdown');
        var templates = require('metalsmith-templates');
        var less = require('metalsmith-less');
        var nav = require('metalsmith-navigation');
        var assets = require('metalsmith-assets');

        var drafts = require('metalsmith-drafts');

        var navTask = nav({
            primary:{
                sortBy: 'nav_sort',
                filterProperty: 'nav_groups',
                // mergeMatchingFilesAndDirs: false,
                // includeDirs: true
github davglass / express-dust / lib / dust.js View on Github external
}
}


// 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;

// This needs a setter TODO
// Disable whitespace compression.
dust.optimizers.format = function (context, node) {
    return node;
};

// Duckpunch Express's res.render() method to use Dust. This is necessary
// because Express doesn't support async template engines by default.
http.ServerResponse.prototype.render = function (view, options, callback) {
    var res = this;

    // Support callback as second arg.
    if (typeof options === 'function') {
        callback = options;
        options  = {};
    }

    callback || (callback = function (err, html) {
        if (err) { res.req.next(err); return; }
github raptorjs-legacy / raptorjs / tools / raptor-cli / scaffolding.js View on Github external
var dust = require('dustjs-linkedin'),
    File = require('raptor/files/File'),
    files = require('raptor/files'),
    path = require('path');

dust.optimizers.format = function(ctx, node) { return node; };

function Scaffolding(cli) {
    this.cli = cli;
}

Scaffolding.prototype = {
    generate: function(options) {
        var scaffoldDir = options.scaffoldDir,
            outputDir = options.outputDir,
            viewModel = options.viewModel,
            afterFile = options.afterFile,
            cli = this.cli,
            logSuccess = cli.logSuccess,
            logWarn = cli.logWarn,
            logError = cli.logSuccess;
github clavery / grunt-generator / tasks / lib / generator.js View on Github external
if(typeof this.options.templateEngine === "function") {
    templateEngines.custom = this.options.templateEngine;
    this.options.templateEngine = "custom";  
  }

  if(this.options.templateEngine === 'handlebars') {
    _.extend(this.options.helpers, this.options.handlebarsHelpers);

    _.forEach(this.options.helpers, function(helper, helperName) {
      Handlebars.registerHelper(helperName, helper);  
    });
  } else if(this.options.templateEngine === 'dust') {
    _.extend(dust.helpers, this.options.handlebarsHelpers, this.options.helpers); 

    if(!this.options.compressWhitespace) {
      dust.optimizers.format = function(ctx, node) { return node; };
    }
  }

  this.frontmatterRegex = new RegExp('^' + this.options.frontmatterDelimiter + '$', 'm');

  try {
    this.frontmatterParser = frontmatterParsers[this.options.frontmatterType.toLowerCase()];
  } catch(e) {
    grunt.log.error('bad frontmatter type: ' + this.options.frontmatterType);
  }

  this.options.grunt = grunt;
  this.options.gruntConfig = grunt.config.data;
  return this;
};