gulp.task('client_templates', function () {
  gulp.src('./src/client/**/*.jade')
    .pipe(jade({ client: true }))
    .pipe(uglify())
    .pipe(wrap({
       deps: ['jade'],
       params: ['jade']
     }))
    .pipe(gulp.dest(DIST_DIR + '/client'));
});
gulp.task('amd', ['script'], function() {
  return gulp.src([
      './lib/js/module.js',
      './lib/js/template.js'
    ])
    .pipe(concat('module.amd.js'))
    .pipe(uglify())
    .pipe(wrap({
      deps: ['angular'],
      params: ['angular'],
      exports: 'angular.module("docsTabsExample")'
    }))
    .pipe(gulp.dest('lib/js'))
});
gulp.task('tpl', function () {
	gulp.src('./client/app/tpl/**/*.jade')
		.pipe(plumber())
		.pipe(jade({
			client: true
		}))
		.pipe(modify())
		.pipe(concat('templates.js'))
		.pipe(insert.prepend('var tpl = {};'))
		.pipe(wrap({
			deps: ['jade'],
			params: ['jade'],
			exports: 'tpl'
		}))
		.pipe(gulp.dest('./client/public/'))
		.pipe(connect.reload());
});
Example #4
0
var jade_compile = function(source_path, dest){

	var jadeOps = {
		client: true,
		basedir: process.cwd() + '/source/jade'
	};
 
	var stream = gulp.src(source_path)
		.pipe( changed(dest, {extension: '.js'}) )
		.pipe( jade(jadeOps) )
			.on( 'error', gutil.log )
		.pipe( wrap({
			deps: ['jade', 'underscore'], 
			params: ['jade', '_']
			}) 
		)
	return stream
};
Example #5
0
gulp.task('templates', function() {
    return gulp.src(paths.templates)
        .pipe(template({
            namespace: 'JST',
            name: function(file) {
                var matches = file.relative.match(/(.+)\.jst$/i);
                return matches ? matches[1] : file.relative;
            }
        }))
        .pipe(concat('templates.js'))
        .pipe(wrap({
            deps: ['underscore'],       // dependency array
            params: ['_'],              // params for callback
            exports: 'window.JST',      // variable to return
            moduleRoot: 'src/js'        // include a module name in the define() call, relative to moduleRoot
        }))
        .pipe(header(banner, {pkg : pkg}))
        .pipe(uglify({
            preserveComments: 'some'
        }))
        .pipe(gulp.dest(dirs.dist + '/js/templates'));
});
Example #6
0
gulp.task('templates', function() {
  // Load templates from the source/templates/ folder relative to where gulp was executed
  gulp.src('source/templates/**/*.hbs')
    // Compile each Handlebars template source file to a template function using Ember's Handlebars
    .pipe(handlebars({
      handlebars: require('ember-handlebars'),
      compiler: compiler.processString
    }))
    .pipe(wrapAmd({
      deps: ['exports'],          // dependency array
      params: ['__exports__'],        // params for callback
      moduleRoot: 'source/',
      modulePrefix: 'rocks/'
    }))
    .pipe(replace(
        /return export default/, 'return __exports__["default"] ='
    ))
    // Concatenate down to a single file
    .pipe(concat('templates.js'))
    // Write the output into the templates folder
    .pipe(gulp.dest('build/js/'));
});
Example #7
0
//Компиляция шаблонов JADE
function compileTemplates() {
    function scanJadeIncludes(jadeFileName, basePath, callback) {
        fs.readFile(jadeFileName, {"encoding": "utf-8"}, function (err, data) {
            if (err) {
                callback(err);
            } else {
                var res = [];
                var tasks = [];
                data = data.split("\n");
                data.forEach(function (line) {
                    line = line.trim().split(/\s+/);
                    if (line[0] == 'include') {
                        line = line[1];
                        if (line.indexOf('.jade') == -1) {
                            line += '.jade';
                        }
                        var fn = path.join(basePath, line);
                        res.push(fn);
                        line = path.join(path.dirname(jadeFileName), line);
                        tasks.push(function (cb) {
                            scanJadeIncludes(line, path.dirname(fn), cb);
                        });
                    }
                });
                async.parallel(tasks, function (err, cbres) {
                    if (err) {
                        console.log(err);
                    }
                    if (cbres && cbres.length) {
                        cbres.forEach(function (r) {
                            if (r && r.length) {
                                r.forEach(function (e) {
                                    if (e && e.length) {
                                        res.push(e);
                                    }
                                });
                            }
                        });
                    }
                    callback(err, res);
                });
            }
        });
    }

    return gulp.src(config.path.jadeFiles)
        .pipe(plumber())
        .pipe(jade({client: true, pretty: true}))
        .pipe(wrap({deps: ['vendor/js/runtime', '{cssIncludePlaceholder}'], params: ['jade']}))
        .pipe(through.obj(function (file, enc, cb) {
            var fn = file.history[0];
            fn = fn.split(path.sep);
            fn = fn[fn.length - 1];
            var css = fn.split('.');
            css[css.length - 1] = 'css';
            css = css.join('.');
            var cssArr = [css];
            var self = this;
            scanJadeIncludes(file.history[0], '.', function (err, res) {
                if (err) {
                    console.log(err);
                }
                if (res && res.length) {
                    res.forEach(function (fn) {
                        cssArr.push(fn.replace(/\.jade$/, '.css').replace(/\\/g, '/'));
                    });
                }
                // TODO: skip css files that absent in current directory with extention "scss"

                file.contents = new Buffer(String(file.contents)
                        .replace("{cssIncludePlaceholder}", 'css!./' + cssArr.join('","css!'))
                );
                self.push(file);
                cb();
            });
        }))
        .pipe(rename({extname: ".jade.js"}))
        .pipe(gulp.dest(config.path.build));
}