Answer the question
In order to leave comments, you need to log in
How to collect html templates from mustache using gulp?
Previously, I did not work with build systems. I'm using Sass/Compass-watch/Mustache for Ruby. I'm tired of a very slow build (more than 6 seconds), I want to switch to gulp build. The assembly and watcher for sass work fine, but I can’t figure it out with mustache.
gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var mustache = require("gulp-mustache-plus");
// Gulp Sass Task
gulp.task('sass', function() {
gulp.src('./scss/{,*/}*.{scss,sass}')
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'));
});
// Gulp Mustache Task
gulp.task('mustache', function() {
gulp.src("./templates/*.mustache")
.pipe(mustache({},{},{
file_1: "partials/*.mustache"
})).pipe(gulp.dest("./"));
});
gulp.task('default', ['sass', 'mustache'], function () {
gulp.watch('./scss/{,*/}*.{scss,sass}', ['sass']);
gulp.watch('./templates/{,*/}*.{mustache}', ['mustache']);
});
.
├── css
├── scss
├── index.html
├── gulpfile.js
└── templates
├── index.mustache
└── partials
└── header.mustache
{{> partials/head }}
<body>
{{> partials/header }}
<div class="wrap">
{{> some_inner_partial }}
<div class="content">
...
</div>
</div>
{{> partials/footer }}
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question