0.1.1 • Published 10 years ago
reorder-attributes v0.1.1
reorder-attributes
Re-format attributes in HTML tags to flow in a specific order. If you always prefer
class
beforeid
or whatever, this module does that.
Install
Install with npm:
npm i reorder-attributes --save-dev
Run tests
npm test
Usage
Pass a string of HTML to reorderAttr()
:
var reorderAttr = require('strip-attributes');
var str = '<h1 id="a" class="b">Foo</h1>';
// Re-order so `class` is before `id`
reorderAttr(str, ['class']);
//=> '<h1 class="b" id="a">Foo</h1>'
Create an array of attributes to order all of your attributes:
var attr = ['id', 'class', 'name', 'href', 'rel', ...];
// only the attributes that actually exist will be re-ordered.
reorderAttr(str, attr);
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on October 16, 2014.