gulp-jade-exports

0.3.1 • Public • Published

gulp-jade-exports

https://travis-ci.org/bloodyowl/gulp-jade-exports

takes all the exports blocks from the given jade files to collect information before running the jade task.

this can be used to collect all the metadata to use it in the templates afterwards.

install

$ npm install gulp-jade-exports

usage

in your jade page

block exports
  -exports.title = "my page title"
  -exports.tags = ["wow", "very", "seo"]

in your gulp file

var gulp = require("gulp")
  , jade = require("gulp-jade")
  , pages = require("gulp-jade-exports")
 
gulp.task("exports", function(){
  return gulp.src("pages/**.jade")
    .pipe(pages())
})
 
gulp.task("pages", ["exports"], function(){
  return gulp.src("pages/**.jade")
    .pipe(jade({
      locals : {
        pages : pages.exports
      }
    }))
})

now all the jade files found in pages will receive a local pages object like this :

{
  "index" : {
    "title" : "my page title",
    "tags" : ["wow", "very", "seo"]
  },
  "about" : {
    "title" : "my page title",
    "tags" : ["some", "other", "tags"]
  }
}

/gulp-jade-exports/

    Package Sidebar

    Install

    npm i gulp-jade-exports

    Weekly Downloads

    10

    Version

    0.3.1

    License

    MIT

    Last publish

    Collaborators

    • bloodyowl