Code Monkey home page Code Monkey logo

gulp-jade-globbing's Introduction

This package has been deprecated & archived

Jade is considered deprecated. Use Pug instead. See the official Pug migration guide: https://pugjs.org/api/migration-v2.html#project-rename

gulp-jade-globbing

Globbing with Jade the easy way.

Expands Jade include and extends statements to allow globbing and placeholders.

Based on gulp-css-globbing.

Install

Install gulp-jade-globbing as a development dependency using npm:

npm install --save-dev gulp-jade-globbing

Usage without options

gulpfile

var jade          = require('gulp-jade');
var jadeGlobbing  = require('gulp-jade-globbing');

gulp.task('jade', function(){
  gulp.src(['src/index.jade'])
    .pipe(jadeGlobbing())
    .pipe(jade())
    .pipe(gulp.dest('build'));
});

src/index.jade

//- ...
include ../foo/bar/**/*.jade
//- ...

Advanced example

gulp task

gulp.task('jade', function(){
  gulp.src(['src/views/**/*.jade'])
    .pipe(jadeGlobbing({
      placeholder: {
        'modules': 'src/modules/**/*.jade',
        'layout': 'src/layout/**/*',
        'default-template': 'src/layout/templates/default.jade',
      }
      ignore: [
        'src/views',
        'src/layout/templates'
      ]
    }))
    .pipe(jade())
    .pipe(gulp.dest('build'));
});

page

extends {default-template}

block includes
  include ../../utilities/**/*.jade
  include ../../base/*.jade
  include {modules}
  include {layout}

block container
  h1 Hello World!

template to extend

block includes
doctype html
html
  head
    meta(charset='utf-8')
    title Hello?

  body
    block container

Options

gulp-jade-globbing can be called with an options object:

gulp.task('jade', function(){
  gulp.src(['src/index.jade'])
    .pipe(jadeGlobbing({
      placeholder: {
        'base': 'src/jade/base/*.jade',
        'modules': 'src/jade/modules/**/*.jade',
        'layout': 'src/jade/layout/**/*',
        'default-template': 'src/jade/layout/templates/default.jade',
      }
      ignore: ['src/jade/layout/templates']
    }))
    .pipe(jade())
    .pipe(gulp.dest('build'));
});

ignore

Type: String or Array

Folders gulp-jade-globbing should ignore.

Default: []

placeholder

Type: Object

Placeholders to use within jade files, e.g. {modules}.

Default: {}

gulp-jade-globbing's People

Contributors

creeation avatar ivanbanov avatar jsahlen avatar scottnath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ivanbanov

gulp-jade-globbing's Issues

Crashing for when use the globbing in a file that is extended

Im trying to use the globbing to load all components from a folder

// default.jade

include ../components/**/*

doctype html
html
  head
    include ../partials/head

    body
      include ../partials/header
      include ../partials/menu
      include ../partials/main
      include ../partials/footer

In a second file Im extending this first one that use globbing

extends ../layouts/default.jade

block main

when I try to compile Im getting a error

Error in plugin 'gulp-jade'
Message:
    /Users/ivanbanov/github/natue/naturals/templates/layouts/default.jade:1
  > 1| include ../components/**/*
    2|
    3| doctype html
    4| html

ENOENT, no such file or directory '/Users/ivanbanov/github/natue/naturals/templates/components/**/*.jade'
Details:
    errno: -2
    code: ENOENT
    path: /Users/ivanbanov/github/natue/naturals/templates/layouts/default.jade
    syscall: open

placeholder option not work correctly in Windows

Faced with a particular problem in Windows.
In MacOS work perfectly.

gulp-jade-globbing: Warning!
  glob pattern did not match any files.
  pattern:      ..\*.jade
  placeholder:  {blocks}

gulpfile:

var blocks = 'app/blocks/**/*.jade';

gulp.task('jade', function(){
  gulp.src(['app/pages/index/index.jade'])
      .pipe(jadeGlobbing({
          placeholder: {
            'blocks': blocks
          }
        }))
    .pipe(jade())
    .pipe(gulp.dest('public/'));
});

index.jade:

include {blocks}

ls app/blocks/logo/:

logo.jade
logo.styl
Win8x64
node -v 4.2.0
gulp -v 3.9.0
gulp-jade-globbing -v 0.1.9

No such file or directory

gulpfile.js

'use strict';

let
  gulp = require('gulp'),
  jade = require('gulp-jade'),
  jadeGlob = require('gulp-jade-globbing');

const
  PATH = {
    APP          : '../application/',
    JADE         : {
      VIEWS      : '../source/jade/views/**/*.jade'
    }
  };

gulp.task('jade', function(){
  gulp
    .src(PATH.JADE.VIEWS)
    .pipe(jadeGlob())
    .pipe(jade())
    .pipe(gulp.dest(PATH.APP));
});

Terminal error:

Error: /Users/delch/Sites/frontskel/source/jade/templates/default.jade:1
  > 1| include ../components/**/*.jade
    2| 
    3| doctype html
    4| - var title = 'Untitled page'

ENOENT: no such file or directory, open '/Users/delch/Sites/frontskel/source/jade/components/**/*.jade'

Files included with include placeholder fails

When trying to retrieve a file with an include placeholder inside a file which is included himself the plugins fails to transform the string.

1| include {components}

ENOENT: no such file or directory, open '/src/templates/components/{components}.jade'

If the file is not included himself there's no issues.
{components} is mapped to /src/templates/mixins/components/*.jade

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.