grunt-html-prettyprinter

Task that beautifies your HTML

npm install grunt-html-prettyprinter
15 downloads in the last week
58 downloads in the last month

grunt-html-prettyprinter Donate on Gittip

Task that beautifies your HTML

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-html-prettyprinter

Then add this line to your project's grunt.js gruntfile:

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

Documentation

grunt.initConfig({
  // Beautify single file
  'html-prettyprinter': {
    single: {
      // HTML file to beauty
      src: 'dirty/index.html',

      // Destination of HTML file
      dest: 'clean/index.html'
    },

    // Multiple files are accepted and concatenated in order by a line feed
    multi: {
      src: ['dirty/index.html', 'dirty/main.html'],
      dest: 'clean/index.html'
    },

    // Lastly, we support the grunt compact format (dest: src)
    'clean/index.html': 'dirty/index.html'
  },
  // Beautify multiple files in a directory
  'html-prettyprinter-dir': {
    multi: {
      // Files to beautify
      src: ['dirty/index.html', 'dirty/main.html'],

      // Directory to output beautified files to
      dest: 'clean/'
    },

    // Minimatch expansion is supported
    expansion: {
      // Expands to ['dirty/index.html', 'dirty/main.html']
      src: ['dirty/*.html'],
      dest: 'clean/'
    },

    // Custom routing is supported
    routing: {
      src: ['dirty/index.html', 'dirty/main.html'],
      dest: 'clean/',
      // Rename all files to .pretty.html
      router: function (file) {
        var filename = path.basename(file);
        return filename.replace('.html', '.pretty.html');
      }
    },

    // Lastly, we support the grunt compact format (dest: src)
    'clean/': ['dirty/index.html', 'dirty/main.html']
  }
});

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 your code using grunt and test via npm test..

Release History

(Nothing yet)

License

Copyright (c) 2012 Todd Wolfson Licensed under the MIT license.

npm loves you