templates - Gulp html templating -
has knew "gulp" plugin compiles(bundles) different files .html extension 1 file? or closer trying achieve?
ex.
build |- html |- header.html |- footer.html |- main-section.html |- index.html dist |- index.html(result)
on index.html file on build
... meta tags ... somewhere inside body tag /* want */ require('build/html/header.html); require('build/html/main-section.html); require('build/html/footer.html); </pre> and output html inside of files. each of files(header, ...) have require also.
p.s. can list of them links, please? alot.
you can use gulp-inject. readme @ github:
in order inject files contents have provide custom transform function, return file contents string. have omit {read: false} option of gulp.src in case. example below shows how inject contents of html partials head of index.html:
gulp.src('./src/index.html') .pipe(inject(gulp.src(['./src/partials/head/*.html']), { starttag: '<!-- inject:head:{{ext}} -->', transform: function (filepath, file) { // return file contents string return file.contents.tostring('utf8') } })) .pipe(gulp.dest('./dest')); and in ./src/index.html:
<!doctype html> <html> <head> <title>my index</title> <!-- inject:head:html --> <!-- contents of html partials injected here --> <!-- endinject --> </head> <body> </body> </html>
Comments
Post a Comment