stringify-attributes
Turn an object into a string of HTML attributes
Last updated 5 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install stringify-attributes 
SYNC missed versions from official npm registry.

stringify-attributes

Turn an object into a string of HTML attributes

Install

$ npm install stringify-attributes

Usage

import stringifyAttributes from 'stringify-attributes';

stringifyAttributes({
	unicorn: '????',
	rainbow: true,
	number: 1,
	multiple: [
		'a',
		'b'
	]
});
//=> ' unicorn="????" rainbow number="1" multiple="a b"'

Note that the string is prepended with a space when there are attributes to simplify using it in a HTML tag.

Related

Current Tags

  • 3.0.0                                ...           latest (5 years ago)

3 Versions

  • 3.0.0                                ...           5 years ago
  • 2.0.0                                ...           7 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (3)

Copyright 2013 - present © cnpmjs.org | Home |