How to use the dustjs-linkedin.compile 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 Postleaf / postleaf / source / modules / dust_engine.js View on Github external
Fs.readFile(file, 'utf8', (err, data) => {
    if(err) return callback(err);

    try {
      // Compile it
      let compiled = Dust.compile(data);

      // Cache it
      if(useCache) {
        templateCache[file] = compiled;
      }

      callback(null, Dust.loadSource(compiled));
    } catch(err) {
      // Show a friendlier error for rendering issues
      let relativePath = Path.relative(__basedir, file);
      return callback(
        new Error('Template Error: ' + err.message + ' in ' + relativePath)
      );
    }
  });
}
github krakenjs / adaro / lib / patch / index.js View on Github external
reader(name, utils.nameify(name), context, function (err, src) {
                                if (err) {
                                    chunk.setError(err);
                                    return;
                                }

                                // It's not a string, so we need to load and compile
                                // before we can evaluate
                                if (typeof src !== 'function') {
                                    src = dust.loadSource(dust.compile(src, name));
                                }

                                if (!config.cache) {
                                    delete self[name];
                                }

                                src(chunk, context).end();
                                active -= 1;
                            });
                        }
github oklai / koala / src / app / scripts / compilers / DustCompiler.js View on Github external
fs.readFile(filePath, 'utf8', function (rErr, code) {
        if (rErr) {
           triggerError(rErr.message);
           return false;
        }

        var jst;
        try {
            jst = dust.compile(code, path.basename(filePath, '.dust'));
        } catch (e) {
            triggerError(e.message);
            return false;
        }

        //write jst code into output
        fs.writeFile(output, jst, 'utf8', function (wErr) {
            if (wErr) {
                triggerError(wErr.message);
            } else {
                emitter.emit('done');
                emitter.emit('always');
            }
        });
    });
};
github darkspotinthecorner / DarkTip / src / darktip.js View on Github external
this.wrapper = function(before, after) {
				before = before || '';
				after  = after  || '';
				wrappperTplIndex   = dust.loadSource(dust.compile((before + '{>"{module.setting.template.index}" /}'   + after), 'wrapper-index'));
				wrappperTplLoading = dust.loadSource(dust.compile((before + '{>"{module.setting.template.loading}" /}' + after), 'wrapper-loading'));
				return self;
			};
			this.getWrappedIndexTplName = function() {
github alexgorbatchev / gulp-typescript-webpack-react-hotreload / gulpfile.ts View on Github external
      .then(([content]) => dust.compile(content, 'index'))
      .then(dust.loadSource)
github clavery / grunt-generator / tasks / lib / generator.js View on Github external
partials.forEach(function(v, i) {
      var contents = grunt.file.read(v);
      var name = path.basename(v, path.extname(v));

      if(me.options.templateEngine === 'handlebars') {
        Handlebars.registerPartial(name, contents);
      } else if(me.options.templateEngine === 'dust') {
        var templateName = name;
        var source = dust.compile(contents, templateName);
        dust.loadSource(source);
      }
    });
  }
github raptorjs-legacy / raptorjs / lib / raptor / i18n / i18n_server.js View on Github external
'template': function(key, value, localeCode, dictionary, dictionaryName, writer) {
            if (Array.isArray(value)) {
                value = value.join('');
            }

            var dust = require('dustjs-linkedin'),
                templateName = dictionaryName + '_' + localeCode + '.' + key;

            require('dustjs-helpers');

            try {
                writer.write(dust.compile(value, templateName));
            } catch(e) {
                logger.error('Error compiling template "' + templateName + '". Template: ' + JSON.stringify(value), e);
            }

            logger.info('Compiled Dust template "' + templateName + '".');

            dictionary[key] = {
                type: 'dust',
                templateName: templateName
            };
        }
    };
github dadi / web / dadi / lib / dust / index.js View on Github external
dust.onLoad = (templateName, opts, callback) => {
    var name
    if (opts && opts.host && templateName.indexOf(opts.host) === -1 && this.templates[opts.host + templateName]) {
      name = opts.host + templateName
    } else {
      name = templateName
    }

    if (!this.templates[name]) {
      return callback({message: 'Template not found: ' + name}, null)
    }

    var compiled = dust.compile(this.templates[name])
    var tmpl = dust.loadSource(compiled)

    return callback(null, tmpl)
  }
}
github paypal / appsforhere / lib / queue.js View on Github external
fs.readFile(templatePath, function (err, file) {
            if (err) {
                logger.error('Failed to read notification template %s - sending to dead letter.', templatePath);
                q.notificationQueue.deadLetter(n);
                return;
            }
            q.notificationTemplates[tname] = dust.compile(file.toString(), tname);
            dust.loadSource(q.notificationTemplates[tname], tname);
            fn();
        });
    }