Nothing Special   »   [go: up one dir, main page]

1.4.0 • Published 4 years ago

posthtml-render v1.4.0

Weekly downloads
522,459
License
MIT
Repository
github
Last release
4 years ago

npm node tests coverage

npm i -D posthtml-render

NodeJS

import { render } from ''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);
<ul class="list">
  <li>one</li>
  <li>two</li>
  <li>three</li>
</ul>
NameTypeDefaultDescription
singleTags{Array<String\|RegExp>}[]Specify custom single tags (self closing)
closingSingleTag{String}>Specify the single tag closing format
quoteAllAttributes{Boolean}truePut double quotes around all tags, even when not necessary.
replaceQuote{Boolean}trueReplaces quotes in attribute values with &quote;.
quoteStyle{0 or 1 or 2}2Specify the style of quote arround the attribute values

singleTags

Specify custom single tags (self closing)

{String}

const render = require('posthtml-render')

const tree = [ { tag: 'name' } ]
const options = { singleTags: [ 'name' ] }

const html = render(tree, options)

result.html

<name>

{RegExp}

const render = require('posthtml-render')

const tree = [ { tag: '%=title%' } ]
const options = { singleTags: [ /^%.*%$/ ] }

const html = render(tree, options)

result.html

<%=title%>

closingSingleTag

Specify the single tag closing format

Formats

const render = require('posthtml-render')

const tree = [ { tag: 'img' } ]
'tag'
const html = render(tree, { closingSingleTag: 'tag' })
<custom></custom>
'slash'
const html = render(tree, { closingSingleTag: 'slash' })
<custom />
'default' (Default)
const html = render(tree)
<img>
'closeAs'
const tree = [ {
  tag: 'custom',
  closeAs: 'default' // Available types: `tag` | `slash` | `default`
} ]
const html = render(tree, { closingSingleTag: 'closeAs' })
<custom>

quoteAllAttributes

Specify if all attributes should be quoted.

true (Default)
<i src="index.js"></i>
false
<i src=index.js></i>

replaceQuote

Replaces quotes in attribute values with &quote;.

true (Default)
<img src="<?php echo $foo[&quote;bar&quote;] ?>">
false
<img src="<?php echo $foo["bar"] ?>">

quoteStyle

2 (Default)

Attribute values are wrapped in double quotes:

<img src="https://example.com/example.png" >
1

Attribute values are wrapped in single quote:

<img src='https://example.com/example.png' >
0

Quote style is based on attribute values (an alternative for replaceQuote option):

<img src="https://example.com/example.png" >
weex-binding-style-loader@parcel-nightly-unofficial/transformer-html@parcel-nightly-unofficial/transformer-posthtmlproject-name-herezable@ianlucas/parcel-bundler@flame-app/f2-reactget3d-viewerposthtml-markdown@everything-registry/sub-chunk-2463xcim-codesandboxsan-cli-markdown-loaderscegsticky-scroll-catchsvg-fill-loadersvg-clrz-loadervite-plugin-move-scriptvitepress-plugin-demoblockvite-plugin-vitepress-code-blockviajes-patch-vuepress-demo-blockchain_diggerlf-ui-kithulk-markdown-loaderinline-css-climggauharhtmltozhhtml-i18n-clihtml-to-react-componentshtml-to-react-components-es6h5-balerkigojgb-plugin-htmlkwasniew-parcel-bundlerlyra-loadernodeppt-parserpackage-example.jsonparcel-bundlerparcel-bundler-forkparcel-bundler-patchparcel-bundler-slparcel-bundler-vueparcel-bundler-without-deasyncparcel-plugin-simplephpparcel-plugin-velocityparcel-plugin-vmparcel-transformer-html-datasrcparcel-transformer-iconifypineglade-bemlinterpineglade-configpineglade-w3cposthtml-bem-linterposthtml-email-remove-unused-cssposthtml-expressionsposthtml-componentposthtmlposthtml-beautifyposthtml-hintposthtml-jsxposthtml-markdownitposthtml-minifierposthtml-modulesposthtml-nunjucksposthtml-svelteposthtml-svg-modeposthtml-tidyposthtml-shikiposthtml-spacelessposthtml-typografposthtml-uglifyposthtml-useposthtml-viewposthtml-w3cposthtml-w3c-validatorpostsvgnewxnative-lazy-loadingst-require-packsr-require-packsipack@ash9g/parcel-bundler@atlaspack/transformer-html@atlaspack/transformer-posthtml@atlaspack/transformer-svg@alexlafroscia/parcel-bundler@beeanco/render-wordpress-post@ayc0/parcel-bundler@bfehub/vuepress-plugin-code-block@bitfirer/vue-qriously@abtnode/cli@achil/parcel-bundler@abidibo/js-word-event@bouygues-telecom/parcel-bundler@devorso/dcountdown@danmarshall/parcel-bundlervuepress-plugin-demo-block-antdvuepress-plugin-code-block-nossrvue-to-dmwebpack-ysywebsite-dependency-graphwebpack-simply
3.0.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.6

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.1

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.5

6 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.7

7 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.0.0

9 years ago