@wxml/parser
Version:
A fast and tolerant wxml parser
53 lines (43 loc) • 1.86 kB
Markdown
## @wxml/parser
[](https://www.npmjs.com/package/@wxml/parser)
[](https://cnpmjs.org/package/@wxml/parser)
[](https://github.com/wxmlfile/wxml-parser/actions/workflows/ci.yml?query=branch%3Amain)
[](https://opensource.org/licenses/MIT)
[](https://github.com/wxmlfile/wxml-parser/pulls)
[](https://twitter.com/s_chenlei)
A fast and tolerant wxml parser
## Installation
```bash
## npm
$ npm install @wxml/parser --save-dev
## yarn
$ yarn add @wxml/parser --dev
## cnpm (for china user)
$ cnpm install @wxml/parser --save-dev
```
## Basic Usage
```javascript
const { parse } = require("@wxml/parser");
const AST = parse(`
<view class="search-contianer">
<view class="search" style="height:{{navHeight}}px;padding-top:{{navTop}}px">
<view class="search-title" src="../../images/actLogo/ytlogo.png">
{{mallName}}
</view>
<input
placeholder-class="search-placeholder"
type="text"
placeholder="please enter keyword for search"
disabled
value="{{name}}"
bindinput="bindinput"
bindtap="goSearch">
</input>
</view>
</view>
`);
console.log("AST structure: ", AST);
```
## Try Play Online
<a href="https://npm.runkit.com/%40wxml%2Fparser"><img src="https://funimg.pddpic.com/mobile_piggy/1b725d0e-5a50-4adc-adbd-793f9912cfd8.svg" width="100px" /></a>
Open [RunKit](https://npm.runkit.com/%40wxml%2Fparser) , and then happy coding !