0.0.20 • Published 2 years ago

parse-html-template v0.0.20

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

简介

解析html/template,生成token树,记录节点数据;

支持:元素节点文本节点注释节点

实例:

`<div data-angular name="angular"
      &style="{width: dataWidth}"
      @change="go($event,'query')">
	子元素:【文本】
    <div style="width: 100px;height: 100px;background-color:#e5e0e1;" 
         &style="{width: dataWidth}"  
         &name="block" 
         @click="emit($event,123)">
    </div>
</div>
<p class="forP bindClass2"
   &class="{bindClass1: class1,bindClass2: class2}">
    我是:{{exp}},{{exp2}}
</p>
<app-child></app-child>
<!-- 注释信息-->`

使用:

let Parser = new parseHTML();
Parser.parse(htmlString);

parse逻辑

0. <                    // 节点|文本
    0.1. <!--           // 注释
    0.2. <nodeName      // 节点
    0.3. </             // 闭合节点
	0.4. 文本
1. 其他                  // 文本

元素节点

{
	tagName: "div"
	type: 1,
    attributes: 
    	['data-angular', 
    	 'name', '=', 'angular', 
         '&style','=', '{width: dataWidth}', 
         '@change', '=', "go($event,'query')"],
	children:[],
	startPosition:{},
	endPosition:{}
}

文本节点

{
	content: "子元素:【文本】"
	type: 3,
    parent:{},
	startPosition:{},
	endPosition:{}
}

注释节点

{
	content: "子元素:【文本】"
	type: 8,
	startPosition:{},
	endPosition:{}
}
0.0.20

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.16

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago