posthtml-miniprogram-replace

0.1.1 • Public • Published

posthtml-miniprogram-replace

介绍

替换小程序 ml 文件属性的 posthtml 插件

安装

yarn add posthtml-miniprogram-replace --dev
npm install posthtml-miniprogram-replace -D

使用

import posthtml from 'posthtml';
import { postHtmlReplace } from 'posthtml-miniprogram-replace';

const result = posthtml([postHtmlReplace({
    sourceHtmlMap: {
      "wx:if": "wx:if",
      "wx:for": "wx:for"
    },
    htmlMap: {
      "wx:if": "tt:if",
      "wx:for": "tt:for"
    },
    extname: '.ttml',
  })
  .process(html, { sync: true })
  .html

console.log(result)

转换前

<include src="./tpl/header.html" />
<import src="./tpl/toast.html" />

<view wx:if="{{ errPage }}" class="error-page"></view>
<view wx:for="{{list}}"></view>

转换后

<include src="./tpl/header.ttml" />
<import src="./tpl/toast.ttml" />

<view tt:if="{{ errPage }}" class="error-page"></view>
<view tt:for="{{list}}"></view>

Package Sidebar

Install

npm i posthtml-miniprogram-replace

Weekly Downloads

1

Version

0.1.1

License

ISC

Unpacked Size

4.02 kB

Total Files

5

Last publish

Collaborators

  • baiweiye