How to use the dustjs-linkedin.load 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
│(( ((  )) ))    http://www.apache.org/licenses/LICENSE-2.0                   │`\ `)(' /'                                                                  │
│                                                                             │
│   Unless required by applicable law or agreed to in writing, software       │
│   distributed under the License is distributed on an "AS IS" BASIS,         │
│   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  │
│   See the License for the specific language governing permissions and       │
│   limitations under the License.                                            │
\*───────────────────────────────────────────────────────────────────────────*/
'use strict';

var state = require('./state'),
    utils = require('./../utils'),
    dust = require('dustjs-linkedin');

if (!dust.load) {
    throw new Error("dustjs-linkedin is not a compatible version; version 2.7.0 changed the API removing dust.load. Please use dustjs-linkedin@~2.6 until new integration points are created.");
}


var MY_SPECIAL_FRIEND = '☃';
var STATE;
var active = 0;

function apply(config, reader) {
    // CABBAGE PATCH - Here comes the fun...
    // In order to provide request context to our `read` method we need to get creative with dust.
    // We don't to overwrite load, but we do want to use its conventions against it.
    dust.__cabbage__ = dust.load;

    if (STATE && STATE.matches(config, reader)) {
        // If the state of the app hasn't changed, don't create
github krakenjs / adaro / lib / patch / index.js View on Github external
function apply(config, reader) {
    // CABBAGE PATCH - Here comes the fun...
    // In order to provide request context to our `read` method we need to get creative with dust.
    // We don't to overwrite load, but we do want to use its conventions against it.
    dust.__cabbage__ = dust.load;

    if (STATE && STATE.matches(config, reader)) {
        // If the state of the app hasn't changed, don't create
        // a new patch, just reapply the existing one.
        dust.load = STATE.patch;
        return;
    }

    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);
github krakenjs / adaro / lib / patch / index.js View on Github external
function applied() {
    return dust.load.name === 'cabbage';
}