Skip to content
This repository was archived by the owner on Apr 21, 2022. It is now read-only.

Commit 2f985a0

Browse files
committed
feat: wx:for and wx:if
1 parent 4288e84 commit 2f985a0

14 files changed

+942
-39
lines changed

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
// coverageDirectory: null,
2828

2929
// An array of regexp pattern strings used to skip coverage collection
30-
coveragePathIgnorePatterns: ['/node_modules/'],
30+
coveragePathIgnorePatterns: ['/node_modules/', 'src/lib/mustache'],
3131

3232
// A list of reporter names that Jest uses when writing coverage reports
3333
coverageReporters: [

package-lock.json

-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"homepage": "https://github.com/AngusFu/wxml2vue#readme",
2424
"dependencies": {
2525
"lodash": "^4.17.11",
26-
"mustache": "^3.0.1",
2726
"parse-entities": "^1.2.2",
2827
"rehype-parse": "^6.0.0",
2928
"rehype-stringify": "^6.0.0",

src/index.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let template = `
55
</view>
66
</template>
77
8-
<template data="{{...staffA}}"></template>
8+
<template is="staffName" data="{{...staffA}}"></template>
99
<template is="staffName" data="{{...staffB}}"></template>
1010
<template is="staffName" data="{{...staffC}}"></template>
1111
@@ -28,6 +28,10 @@ let template = `
2828
<view>{{"hello" + name}}</view>
2929
<view>{{object.key}} {{array[0]}}</view>
3030
</view>
31+
<view wx:for="{{array}}" wx:for-index="idx" wx:for-item="itemName">
32+
{{idx}}: {{itemName.message}}
33+
</view>
34+
3135
`
3236

3337
// 0. 注意针对 template content 的处理
@@ -41,9 +45,15 @@ let template = `
4145

4246
const proccess = require('./proccess')
4347

44-
proccess(template)
48+
proccess(template, [
49+
require('./transform/mustache/text'),
50+
require('./transform/mustache/template-is'),
51+
require('./transform/mustache/directives'),
52+
require('./transform/mustache/attrs'),
53+
require('./transform/directives/wx-for')
54+
])
4555
.then(file => {
46-
console.log(file)
56+
console.log(file.contents)
4757
})
4858
.catch(e => {
4959
console.error(proccess.report(e))

0 commit comments

Comments
 (0)