Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
4
increased by100%
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

使用

  1. 新建一个.js文件
  2. 添加如下代码
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc