npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

reorder-attributes

0.1.1

@jonschlinkert

npmHomeRepoSnykSocket
Downloads:238
$ npm install reorder-attributes
DailyWeeklyMonthlyYearly

reorder-attributes NPM version

Re-format attributes in HTML tags to flow in a specific order. If you always prefer class before id 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

  • github/jonschlinkert
  • twitter/jonschlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on October 16, 2014.