Skip to content

Commit

Permalink
Merge pull request #5 from tvararu/master
Browse files Browse the repository at this point in the history
Add jade template parser through templatizer.
  • Loading branch information
tvararu committed Aug 11, 2014
2 parents e00d1d6 + 655ca22 commit 3135f48
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist
npm-debug.log
.tmp
coverage
app/js/lib/templates.js

File renamed without changes.
3 changes: 2 additions & 1 deletion app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
require('famous-polyfills');

var _ = require('lodash');
var cordova = require('./cordova-shim');
var $ = require('jquery');
var cordova = require('./cordova-shim');
var maps = require('./maps');
var templates = require('./lib/templates');

module.exports = {
launch: _.once(function () {
Expand Down
4 changes: 3 additions & 1 deletion app/js/maps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var ol = require('./ol');
var ol = require('./lib/ol');

var Maps = {
createMap: function (opts) {
Expand All @@ -20,6 +20,7 @@ var Maps = {
extent: extent
});

/* istanbul ignore next */
mapLayer.on('precompose', function(event) {
var ctx = event.context;
ctx.save();
Expand All @@ -43,6 +44,7 @@ var Maps = {
ctx.setTransform(1, 0, 0, 1, 0, 0);
});

/* istanbul ignore next */
mapLayer.on('postcompose', function(event) {
var ctx = event.context;
ctx.restore();
Expand Down
6 changes: 6 additions & 0 deletions app/templates/article.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include mixins

p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+do-stuff()

Empty file removed app/templates/body.jade
Empty file.
3 changes: 0 additions & 3 deletions app/templates/head.jade

This file was deleted.

3 changes: 3 additions & 0 deletions app/templates/mixins.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mixin do-stuff()
p stuff!

7 changes: 7 additions & 0 deletions app/templates/test/ceva.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include ../mixins

+do-stuff()

p loremus ipsumus


14 changes: 7 additions & 7 deletions gulp/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ var exec = require('child_process').exec;
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var istanbul = require('browserify-istanbul');

var browserSync = require('browser-sync');
var templatizer = require('templatizer');

gulp.task('clean', function () {
return gulp.src(paths.tmp, { read: false })
Expand All @@ -34,15 +34,15 @@ gulp.task('index.html', function () {
.pipe(browserSync.reload({stream: true}));
});

gulp.task('jade', function () {
return gulp.src(paths.app + '/*.html')
.pipe(gulp.dest(paths.tmp))
.pipe(browserSync.reload({stream: true}));
gulp.task('templates', function () {
templatizer(paths.app + '/templates', paths.app + '/js/lib/templates.js');
});

gulp.task('js', function () {
gulp.task('js', ['templates'], function () {
var bundleStream = browserify(paths.app + '/js/main.js')
.transform(istanbul)
.transform(istanbul({
ignore: ['**/lib/**']
}))
.bundle();

return bundleStream
Expand Down
2 changes: 1 addition & 1 deletion gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var browserSync = require('browser-sync');

gulp.task('watch:common', ['build'], function () {
gulp.watch(paths.app + '/index.jade', ['index.html']);
gulp.watch(paths.app + '/templates/*.jade', ['jade']);
gulp.watch(paths.app + '/templates/*.jade', ['templates']);
gulp.watch(paths.app + '/**/*.js', ['js:no-istanbul']);
gulp.watch(paths.app + '/**/*.css', ['css']);
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"psi": "^0.1.1",
"require-dir": "^0.1.0",
"should": "^4.0.4",
"templatizer": "^0.3.6",
"vinyl-source-stream": "^0.1.1",
"when": "^3.4.3"
}
Expand Down

0 comments on commit 3135f48

Please sign in to comment.