[![npm][npm]][npm-url] [![node][node]][node-url] [![deps][deps]][deps-url] [![tests][tests]][tests-url] [![coverage][cover]][cover-url] [![chat][chat]][chat-url]
PostHTML

PostHTML Render

Renders a PostHTML Tree to HTML/XML

Install

```bash npm i -D posthtml-render ``` > ℹī¸ This module is also available for [bower](http://bower.io) and as an AMD, CommonJS and IIFE (global) module, uncompressed and compressed

Usage

### `NodeJS` ```js const render = require('posthtml-render') const tree = [] const node = {} node.tag = 'ul' node.attrs = { class: 'list' } node.content = [ 'one', 'two', 'three' ].map((content) => ({ tag: 'li', content })) tree.push(node) const html = render(tree, options) ``` ```html ``` ### `🌐 Browser` ```html Title ```

Options

|Name|Type|Default|Description| |:--:|:--:|:-----:|:----------| |**[`singleTags`](#singletags)**|`{Array}`|`[]`|Specify custom single tags (self closing)| |**[`closingSingleTag`](#closingSingleTag)**|`{String}`|[`>`](#default)|Specify the single tag closing format| ### `singleTags` Specify custom single tags (self closing) ### `{String}` ```js const render = require('posthtml-render') const tree = [ { tag: 'name' } ] const options = { singleTags: [ 'name' ] } const html = render(tree, options) ``` **result.html** ```html ``` #### `{RegExp}` ```js const render = require('posthtml-render') const tree = [ { tag: '%=title%' } ] const options = { singleTags: [ '/^%.*%$/' ] } const html = render(tree, options) ``` **result.html** ```html <%=title%> ``` ### `closingSingleTag` Specify the single tag closing format #### `Formats` ```js const render = require('posthtml-render') const tree = [ { tag: 'img' } ] ``` ##### `'tag'` ```js const html = render(tree, { closingSingleTag: 'tag' }) ``` ```html ``` ##### `'slash'` ```js const html = render(tree, { closingSingleTag: 'slash' }) ``` ```html ``` ##### `'default' (Default)` ```js const html = render(tree) ``` ```html ``` [npm]: https://img.shields.io/npm/v/posthtml-render.svg [npm-url]: https://npmjs.com/package/posthtml-render [node]: https://img.shields.io/node/v/posthtml-render.svg [node-url]: [deps]: https://david-dm.org/posthtml/posthtml-render.svg [deps-url]: https://david-dm.org/posthtml/posthtml-render [tests]: http://img.shields.io/travis/posthtml/posthtml-render.svg [tests-url]: https://travis-ci.org/posthtml/posthtml-render [cover]: https://coveralls.io/repos/github/posthtml/posthtml-render/badge.svg [cover-url]: https://coveralls.io/github/posthtml/posthtml-render [chat]: https://badges.gitter.im/posthtml/posthtml.svg [chat-url]: https://gitter.im/posthtml/posthtml