Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c490a6d

Browse files
committed
Swig/twig and font
1 parent 41ec88d commit c490a6d

29 files changed

+903
-684
lines changed

.npm/Gulpfile.js

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,17 @@ var gulp = require('gulp'),
1010
jslint = require('gulp-jslint'),
1111
jsmin = require('gulp-jsmin'),
1212
rename = require('gulp-rename'),
13+
swig = require('gulp-swig'),
14+
custom_filters = require('./filter/custom_filters.js'),
1315
reload = browserSync.reload,
1416
src = {
1517
scss: '../scss/*.scss',
1618
appScss: '../app/scss/*.scss',
1719
css: '../css',
18-
html: '../app/index.html',
20+
swig: '../app/templates/*.twig',
1921
js: '../src/*.js',
2022
};
2123

22-
/**
23-
* Start the BrowserSync Static Server + Watch files
24-
*/
25-
gulp.task('default', ['sass', 'appScss', 'js', 'html'] , function () {
26-
browserSync({
27-
server: '../app',
28-
});
29-
30-
gulp.watch(src.scss, ['sass']);
31-
gulp.watch(src.appScss, ['appScss']);
32-
gulp.watch(src.js, ['js']);
33-
gulp.watch(src.html, ['html']);
34-
});
35-
3624
/**
3725
* Kick off the sass stream with source maps + error handling
3826
*/
@@ -66,9 +54,7 @@ gulp.task('sass', function () {
6654
*/
6755
gulp.task('appScss', function () {
6856
return sassStream(src.appScss)
69-
.pipe(gulp.dest(src.css))
7057
.pipe(gulp.dest('../app/css'))
71-
.pipe(filter("**/*.css"))
7258
.pipe(reload({stream: true}));
7359
});
7460

@@ -92,15 +78,37 @@ gulp.task('js', function () {
9278
.pipe(rename({suffix: '.min'}))
9379
.pipe(gulp.dest('../app/js/'))
9480
.pipe(gulp.dest('../'))
95-
.pipe(reload({stream: true}));
81+
.on('end', reload);
82+
});
83+
84+
gulp.task('templates', function() {
85+
gulp.src('../app/templates/index.twig')
86+
.pipe(swig({
87+
load_json: true,
88+
json_path: '../temapltes/json_data/',
89+
setup: function(swig) {
90+
for (var key in custom_filters) {
91+
swig.setFilter(key, custom_filters[key]);
92+
}
93+
},
94+
}))
95+
//.pipe(prettify({indent_char: ' ', indent_size: 2}))
96+
.pipe(gulp.dest('../app'))
97+
.on('end', reload);
9698
});
9799

98100
/**
99-
* Generate templates.
101+
* Start the BrowserSync Static Server + Watch files
100102
*/
101-
gulp.task('html', function () {
102-
return gulp.src(src.html)
103-
.pipe(prettify({indent_char: ' ', indent_size: 2}))
104-
.pipe(rename({suffix: '.pretty'}))
105-
.pipe(gulp.dest('../app'));
103+
gulp.task('serve', ['sass', 'appScss', 'js', 'templates'] , function () {
104+
browserSync({
105+
server: '../app',
106+
});
107+
108+
gulp.watch(src.scss, ['sass']);
109+
gulp.watch(src.appScss, ['appScss']);
110+
gulp.watch(src.js, ['js']);
111+
gulp.watch(src.swig, ['templates']);
106112
});
113+
114+
gulp.task('default', ['serve']);

0 commit comments

Comments
 (0)