🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

json_script

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json_script

css precessor

0.0.2
latest
npm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

json to css

类似于less、sass这样的css预处理器,这里采用json格式的语法来编写css,如下所示:

json文件:

{
	'.wrap': {
		'margin-top': '20px',
		'padding': '20px',
		'color': '#444',
		p: {
			'padding-top': '20px',
			'font-size': '28px'
		}
	}
}

生成的css:

.wrap {
  margin-top: 20px;
  padding: 20px;
  color: #444;
}
.wrap p {
  padding-top: 20px;
  font-size: 28px;
}

安装

npm install --save json_script

使用

  • 新建一个.js文件
  • 添加如下代码
var json_script = require('json_script');

json_script(function(convert) {
    convert.css({
        '.wrap': {
            'margin-top': '20px',
            'padding': '20px',
            'color': '#444',
            p: {
                'padding-top': '20px',
                'font-size': '28px'
            }
        }
    });
}).render(function(css){
	console.log("渲染后的css:");
	console.log(css);
})

资源

  • 文档地址: http://www.yangxiaofu.com/json_script
  • github: https://github.com/xiaofuzi/json_script

Keywords

css

FAQs

Package last updated on 13 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts