Example #1
0
    return function onLoad(name, context, callback) {

        var out, options, global, locals, locality, props;

        global = context.global;
        locals = context.get('context');
        locality = util.localityFromLocals(locals);
        props = res.resolve(name, locality).file || i18n.contentPath;

        options = {
            src: path.join(config.views, name + '.dust'),
            props: props
        };

        out = bl(function (err, data) {
            if (err) {
                return callback(err);
            }

            try {
                var compiledDust = dustjs.compile(data.toString('utf-8'), name);
                callback(null, compiledDust);
            } catch (e) {
                callback(e);
            }
        });

        localizr.createReadStream(options).pipe(out);
    };
Example #2
0
    return function onLoad(name, context, callback) {

        var out, options, global, locals, locality, props;

        global = context.global;
        locals = context.get('context');
        locality = util.localityFromLocals(locals);
        props = res.resolve(name, locality).file || i18n.contentPath;
          if (props==null || props==i18n.contentPath) {
            locality = locality ? util.parseLangTag(locality) : res._fallback;
            props = path.join(i18n.contentPath,locality.country,locality.language);
          }

        options = {
            src: path.join(config.views, name + '.dust'),
            props: props,
            enableMetadata: config.enableMetadata
        };

        out = bl(function (err, data) {
            if (err) {
                return callback(err);
            }

            try {
                var compiledDust = dustjs.compile(data.toString('utf-8'), name);
                callback(null, compiledDust);
            } catch (e) {
                callback(new VError(e, 'Problem rendering dust template named %s', name));
            }
        });

        localizr.createReadStream(options).pipe(out);
    };
Example #3
0
    mkdirp(path.dirname(destFile), function (err) {
        if (err) {
            deferred.reject(err);
            logger.error('Failed to generate', srcFile, ' from ', destFile, 'error', err, '\n');
            return;
        }
        var out = concat({ encoding: 'string' }, function (data) {
            fs.writeFile(destFile, data, function (err) {
                if (err) {
                    deferred.reject(err);
                    logger.error('Failed to generate', srcFile, ' from ', destFile, 'error', err, '\n');
                    return;
                }
                logger.write('Generated ', destFile, '\n');
                deferred.resolve(destFile);
            });
        });

        localizr.createReadStream(opt).pipe(out);
    });