How to use the dustjs-linkedin.cache 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 krakenjs / adaro / lib / patch / index.js View on Github external
STATE = state.create(config, reader, dust.load = function cabbage(name, chunk, context) {
        var view, notCached, views;

        active += 1;

        view = name;
        notCached = !dust.cache[name];
        views = utils.resolveViewDir(context.global, MY_SPECIAL_FRIEND);

        if (notCached && views !== MY_SPECIAL_FRIEND) {
            // We exploit the cache to hook into load/onLoad behavior. Dust first checks the cache before
            // trying to load (using dust.cache[name]), so if we add a custom getter for a known key we can
            // get dust to call our code and replace its behavior without changing its internals.
            view = MY_SPECIAL_FRIEND;
            Object.defineProperty(dust.cache, view, {

                configurable: true,

                get: function () {
                    var self = this;

                    // Remove the getter immediately (must delete as it's a
                    // getter. setting it to undefined will fail.)
github davglass / express-dust / lib / dust.js View on Github external
res.__dynamicHelpers = {};
            for (var key in dynamicHelpers) {
                res.__dynamicHelpers[key] = dynamicHelpers[key].call(
                    res.app,
                    res.req,
                    res);
            }
        }
        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 krakenjs / adaro / lib / patch / index.js View on Github external
STATE = state.create(config, reader, dust.load = function cabbage(name, chunk, context) {
        var view, notCached, views;

        active += 1;

        view = name;
        notCached = !dust.cache[name];
        views = utils.resolveViewDir(context.global, MY_SPECIAL_FRIEND);

        if (notCached && views !== MY_SPECIAL_FRIEND) {
            // We exploit the cache to hook into load/onLoad behavior. Dust first checks the cache before
            // trying to load (using dust.cache[name]), so if we add a custom getter for a known key we can
            // get dust to call our code and replace its behavior without changing its internals.
            view = MY_SPECIAL_FRIEND;
            Object.defineProperty(dust.cache, view, {

                configurable: true,

                get: function () {
                    var self = this;

                    // Remove the getter immediately (must delete as it's a
                    // getter. setting it to undefined will fail.)
                    delete this[view];

                    return function (chunks, context) {
                        function onChunk(chunk) {
                            reader(name, utils.nameify(name), context, function (err, src) {
                                if (err) {
                                    chunk.setError(err);
                                    return;
github krakenjs / adaro / test / race.js View on Github external
afterEach(function () {
        dustjs.cache = {};
    });
github DecentCMS / DecentCMS / modules / core / ui / services / dust-view-engine.js View on Github external
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,
        dust.loadSource(dust.compile(template.toString(), templatePath))
      );
      done(getDustTemplate(templatePath));
    });
  };
};
github dadi / web / dadi / lib / dust / index.js View on Github external
Dust.prototype.clearCache = function () {
  dust.cache = {}
}