grunt-glob-html

0.3.1 • Public • Published

grunt-glob-html

Add globbing to your HTML

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-glob-html --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-glob-html');

The "globhtml" task

Overview

This grunt task allows to use glob syntax when you specify src in script or link tags.

Initial HTML

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>glob-html example</title>
    
    <link href="css/style3.css" rel="stylesheet" type="text/css">
    <link href="css/*.css" rel="stylesheet" type="text/css">
    
    <script src="scripts/subfolder/*"></script> 
    <script src="scripts/*"></script> 
    <script src="scripts/script2.js"></script> 
</head>
<body>
    <p>glob-html example</p>
</body>
</html>

HTML after "globhtml"

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>glob-html example</title>
    
    <link href="css/style3.css" rel="stylesheet" type="text/css">
    <link href="css/style1.css" rel="stylesheet" type="text/css">
    <link href="css/style2.css" rel="stylesheet" type="text/css">
    
    <script src="scripts/subfolder/script1.js"></script> 
    <script src="scripts/subfolder/script2.js"></script> 
    <script src="scripts/script1.js"></script> 
    <script src="scripts/script3.js"></script> 
    <script src="scripts/script2.js"></script> 
</head>
<body>
    <p>glob-html example</p>
</body>
</html>

See tests for more detailed HTML examples.

Options

Currently no options provided.

Usage Examples

Single HTML content

grunt.initConfig({
  globhtml: {
    content: {
      src: 'www/content.html',
      dest: 'www/content.result.html'
    }
});

Multiple HTML content

grunt.initConfig({
  globhtml: {
    content: {
      src: 'www/*.html',
      dest: 'www/result/'
    }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

(Nothing yet)

/grunt-glob-html/

    Package Sidebar

    Install

    npm i grunt-glob-html

    Weekly Downloads

    3

    Version

    0.3.1

    License

    none

    Last publish

    Collaborators

    • gevgeny