GithubHelp home page GithubHelp logo

gulp-x-includer's Introduction

gulp-x-includer

Gulp plugin for include js/css/html... any file.

Install

$ npm install gulp-x-includer --save-dev

Syntax

Default supported 4 comment syntax.

'' or ""
<!-- include "path/to/xxx.html" -->
// include "path/to/xxx.js"
/* include "path/to/xxx.css" */
# include "./include/test.txt"

HTML :

<!-- include "path/to/xxx.html" -->

JavaScript :

// include "path/to/xxx.js"

CSS :

/* include "path/to/xxx.css" */

Other file (e.g. markdown .md, configure .conf, .ini ...) :

# include "./include/test.txt"

Examples

test.html :

<!DOCTYPE html>
<html>
<head>
    <title>Test HTML Document</title>
    <meta charset="UTF-8">
    <!-- fdsfsadf -->
    <meta name="description" content="">
    <meta name="keywords" content="">
    <style>
        /* include "./css/test.css" */
        /* fasdfadsfsadf */
        div {color: red;}
        /* fasdfadsfsadf */
        /* include "./css/test1.css" */
        p {color: green;}
        /* fasdfadsfsadf */
        strong {color: yellow;}
        /* fasdfadsfsadf */
        /* include "./css/test2.css" */
    </style>
</head>
<body>
    <!-- include "./html/header.html" -->
    <!-- fdsfsadf -->
    <!-- test -->
    <p>TEST</p>
    <!-- include "./html/main.html" -->
    <!-- fdsfsadf -->
    <div>TEST</div>
    <!-- include "./html/footer.html" -->
    <!-- fdsfsadf -->
    
    <script>
        // include './js/test.js'
        var a = 234567890, b, c;
        // fadsfasdfdsafsdfsd
        // fadsfasdfdsafsdfsd
        // fadsfasdfdsafsdfsd
        // fadsfasdfdsafsdfsd
        // include './js/functions.js'

        $(function(){
            alert(345678);
        });
    </script>
</body>
</html>

Gulpfile.js :

var gulp         = require('gulp');
var includer     = require("gulp-x-includer");

gulp.task("include", function(){
    gulp.src(["./*.html", "./*.css", "./*.js"])
    .pipe(includer())
    .pipe(gulp.dest("./dist"));
});

Build :

$ gulp include

Options

{
    debug        : true | false,         // print file includes for console.log(), default false.
    debugOptions : true | false,         // print options object for console.log(), default false.
    regexs       : {},                   // define you include regex
    transform    : function(content) {}  // transform include file content
}

Changes

Change logs

License

The MIT License.

Copyright (c) 2015 Pandao

gulp-x-includer's People

Contributors

pandao avatar

Watchers

 avatar  avatar  avatar

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.