Socket
Socket
Sign inDemoInstall

posthtml-render

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthtml-render - npm Package Compare versions

Comparing version 0.0.0 to 1.0.0

.npmignore

19

package.json
{
"name": "posthtml-render",
"version": "0.0.0",
"version": "1.0.0",
"description": "Render PostHTMLTree to HTML/XML",
"main": "index.js",
"main": "lib/posthtml-render.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npm run build && npm run lint && npm run coverage",
"lint": "jshint lib/ && jscs lib/ -v",
"coverage": "istanbul cover --report text --report html --report lcov node_modules/mocha/bin/_mocha",
"build": "uglifyjs lib/posthtml-render.js -c \"evaluate=false\" -o posthtml-render.min.js"
},

@@ -25,3 +28,11 @@ "repository": {

},
"homepage": "https://github.com/voischev/posthtml-render#readme"
"homepage": "https://github.com/voischev/posthtml-render#readme",
"devDependencies": {
"chai": "^3.3.0",
"istanbul": "^0.4.0",
"jscs": "^2.3.4",
"jshint": "^2.8.0",
"mocha": "^2.3.3",
"uglifyjs": "^2.4.10"
}
}
# posthtml-render
[![npm version](https://badge.fury.io/js/posthtml-render.svg)](http://badge.fury.io/js/posthtml-render)
[![Build Status](https://travis-ci.org/voischev/posthtml-render.svg?branch=master)](https://travis-ci.org/voischev/posthtml-render?branch=master)
[![Coverage Status](https://coveralls.io/repos/voischev/posthtml-render/badge.svg?branch=master)](https://coveralls.io/r/voischev/posthtml-render?branch=master)
Render [PostHTML](http://github.com/posthtml/posthtml) Tree to HTML/XML.
More info for [PostHTMLTree](https://github.com/posthtml/posthtml#posthtml-json-tree-example)
## Install
[NPM](http://npmjs.com) install
```
$ npm install posthtml-render
```
is also available for [bower](http://bower.io) and as an AMD, CommonJS, and globals module, uncompressed and compressed.
## Usage
__In NodeJS__
```js
var render = require('posthtml-render');
var titleObj = { tag: 'h1' };
titleObj.attrs = { class: 'heading' };
titleObj.content = ['Title'];
clonsole.log(render(titleObj/*, options */));
// <h1 class="heading">Title</h1>
```
__In Browser__
```html
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<script type="text/javascript" src="./bower_components/posthtml-render/posthtml-render.min.js"></script>
<script type="text/javascript">
window.onload = function() {
document.body.innerHTML = postHTMLRender({ tag: 'h1', attrs: { style: 'color: red;' }, content: ['Title'] });
};
</script>
</head>
<body>
</body>
</html>
```
## Options
### singleTags
Array tags for extend default list single tags
__Default__: `[]`
*Options* `{ singleTags: ['rect', 'custom'] }`
```html
...
<div>
...
<rect>
<custom>
</div>
```
### closingSingleTag
Option to specify version closing single tags.
Accepts values: `default`, `slash`, `tag`.
__Default__: `default`
*Options* `{ closingSingleTag: 'default' }`
```html
<img>
```
*Options* `{ closingSingleTag: 'slash' }`
```html
<img />
```
*Options* `{ closingSingleTag: 'tag' }`
```html
<img></img>
```
## License
[MIT](LICENSE)
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