miniprogram-posthtml-render
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

miniprogram-posthtml-render

Fork from posthtml/posthtml-render@1.3.0

posthtml-render做如下变更

  1. 默认单标签元素:
[
 'area',
  'base',
  'br',
  'col',
  'command',
  'embed',
  'hr',
  'img',
  'input',
  'keygen',
  'link',
  'menuitem',
  'meta',
  'param',
  'source',
  'track',
  'wbr'
]

替换为适用于小程序的:

[
  'wxs',
  'input',
  'textarea',
  'audio',
  'icon',
  'progress',
  'rich-text',
  'checkbox',
  'radio',
  'slider',
  'switch',
  'live-player',
  'live-pusher',
  'voip-room',
  'canvas',
  'ad',
  'ad-custom',
  'official-account',
  'open-data',
  'web-view',
]
// image, video可以有内容
  1. 添加removeSpaceBetweenAttributes选项用于压缩, quoteAllAttributes同时为true生效。
  <input class="phone" type="number" />

->

<input class="phone"type="number"/>
<input class="phone" type="number" disabled />

->

<input class="phone"type="number" disabled/>
  1. 将属性值为空字符串的属性只保留key, 以支持<input disabled />写法。posthtml-parser会将disabled解释为{ "disabled": "" }
  2. 指定closingSingleTag且内容为空的标签视为单标签:<view></view> => <view />

Usage

$ yarn add miniprogram-posthtml-render -D
const render = require('miniprogram-posthtml-render');

render(true, options);

Package Sidebar

Install

npm i miniprogram-posthtml-render

Weekly Downloads

7

Version

1.0.1

License

MIT

Unpacked Size

21.7 kB

Total Files

6

Last publish

Collaborators

  • princekinwdk