Skip to content

📮 Sorting of the tag attributes in the specified order.

License

Notifications You must be signed in to change notification settings

mrmlnc/posthtml-attrs-sorter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

posthtml-attrs-sorter

A PostHTML plugin for sort attribute of the tag based on the given order.

Travis NPM version devDependency Status devDependency Status

Install

$ npm i -D posthtml-attrs-sorter

Why?

To follow the guidelines for writing code such as Code Guide by @mdo.

Usage

const posthtml = require('posthtml');
const attrsSorter = require('posthtml-attrs-sorter');
const htmlRaw = fs.readFileSync('path/to/file.html');

posthtml()
  .use(attrsSorter({
    // Options
  }))
  .process(htmlRaw)
  .then(function(result) {
     fs.writeFileSync('path/to/file.html');
  })

You can also use this plugin in the PostHTML plugin to Gulp or Grunt.

Options

order

{
  "order": [
    "class", "id", "name",
    "data-.+", "ng-.+", "src",
    "for", "type", "href",
    "values", "title", "alt",
    "role", "aria-.+",
    "$unknown$"
  ]
}

An array of attributes in the correct order.

Plugins for editors and IDE

Changelog

See the Releases section of our GitHub project for changelogs for each release version.

License

MIT.

About

📮 Sorting of the tag attributes in the specified order.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published