jthomas jthomas - 1 year ago 154
Javascript Question

Compile HTML partials with gulp.js

Is there a plugin available for Gulp that does the same thing as Assemble does for Grunt?

I would like to run a task for Gulp that assembles HTML partials, but I cannot find a plugin. Has anyone used one and can you provide a link to it?

UPDATE: 4/21/2016

I just wanted to update this with what I've been using to do this lately. I've been primarily using Twig.js as a frontend templating language with Gulp (you could also use Nunjucks, Swig.js, Handlebars etc.). I've also been using gulp-data when I want to use JSON data for my templates. You can see a quick rundown of how I'm using this approach on a blog post I wrote.

Article: Frontend templating with Gulp and Twig.js

Answer Source

Yes, you can do it with this plugin called gulp-file-include

Example :

# index.html

<!DOCTYPE html>
  @@include('./var.html', {
    "name": "haoxin",
    "age": 12345

# view.html


# var.html

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download