Here is how I added support for Jade templates to my workflow with Ionic.
##What is Jade?
Jade is a robust, elegant, feature rich template engine for nodejs. It lets you write your views in Jade instead of pure HTML.
Have a look at the example code in: http://jade-lang.com/
##What do I need?
Install the gulp-jade plugin. Go to your Ionic app directory then type:
npm install gulp-jade --save-dev
##What files do I need to edit?
- gulp.js
- ionic.project
Edit your gulp.js file and add this line to the top of the file:
var jade = require( 'gulp-jade' );
Edit the path variable to look like this:
var paths = {
sass: ['./scss/**/*.scss'],
jade: ['./jade/**/*.jade']
};
Add jade to default task:
gulp.task( 'default', ['sass', 'jade'] );
Then add the jade task itself:
gulp.task( 'jade', function (done) {
gulp.src( paths.jade )
.pipe( jade() )
.pipe( gulp.dest( './www/' ) )
.on( 'end', done );
} );
After that, modify the watch task to look like this:
gulp.task( 'watch', function() {
gulp.watch( paths.sass, ['sass'] );
gulp.watch( paths.jade, ['jade'] );
} );
And finally if you want live reload to work with your jade templates, modify gulpStartupTasks in ionic.project to this:
"gulpStartupTasks": [
"jade",
"sass",
"watch"
]
##Where do I put my .jade files?
Create a jade directory in your top level app folder (should be a sibling of the sass directory). Whatever structure you put inside there will be mirrored to www.
Create some jade templates in there then run:
ionic serve
Modify any of them and watch your browser instantly reload your views!
Enjoy.