Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

jotform/css.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f6f741d · Aug 5, 2021

History

45 Commits
Apr 19, 2016
Feb 28, 2018
Feb 28, 2018
Jan 14, 2015
Apr 19, 2016
Jan 14, 2015
Jan 14, 2015
Mar 1, 2018
Feb 28, 2018
Feb 28, 2018
Aug 5, 2021
Mar 1, 2018

Repository files navigation

css.js Build Status

A lightweight, battle tested, fast, css parser in JavaScript

Why?

Please read the story behind it [here] [here]: https://medium.com/jotform-form-builder/writing-a-css-parser-in-javascript-3ecaa1719a43

Demo

Check out plunker demo

Development

Following commands will prepare development enviroment by installing dependencies:

npm install

And to execute unit tests and produce css.min.js, execute

grunt

How To Install

npm install jotform-css.js

How To Use

On the browser

Simply parse css string, and log the output

<script type="text/javascript" src="css.min.js"></script>
<script type="text/javascript">
	var cssString = ' .someSelector { margin:40px 10px; padding:5px}';
	//initialize parser object
	var parser = new cssjs();
	//parse css string
	var parsed = parser.parseCSS(cssString);

	console.log(parsed);
</script>

On the server

var cssString = ' .someSelector { margin:40px 10px; padding:5px}';
//require parser constructor
var cssjs = require("./css.js");
//initialize parser object
var parser = new cssjs.cssjs();
//parse css string
var parsed = parser.parseCSS(cssString);

console.log(parsed);