Skip to content
main
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

css-declarations

Build Coverage Downloads Size

Parse and stringify CSS declarations (such as the HTML style attribute).

Install

npm:

npm install css-declarations

Use

var cssDeclarations = require('css-declarations')

var values = cssDeclarations.parse(`
  color:/*red*/purple;
  -webkit-border-radius: 3px !important;;
`)
// => {color: 'purple', webkitBorderRadius: '3px !important'}

cssDeclarations.stringify(values)
// => 'color: purple; -webkit-border-radius: 3px !important;'

API

cssDeclarations.parse(value[, options])

Parse CSS declarations from string to object.

options
  • warning (Function) — When given, warning is invoked when an error is encountered.
Returns

Object.<string> — Declarations.

cssDeclarations.stringify(values)

Serialize CSS declarations from object to string.

Returns

string — Serialized declarations.

function warning(reason, offset)

Invoked when an error occurs. Errors come from reworkcss/css.

Parameters
  • reason (string) — English reason for error;
  • offset (number) — Index-based position of error.

License

MIT © Titus Wormer

You can’t perform that action at this time.