-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathtag.ts
More file actions
40 lines (32 loc) · 1017 Bytes
/
tag.ts
File metadata and controls
40 lines (32 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type { IMap } from "src/types";
import type { XmlGeneralNode, XmlTextNode } from "src/xml";
export const TagDisposition = Object.freeze({
Open: "Open",
Close: "Close",
SelfClosed: "SelfClosed"
} as const);
export type TagDisposition = typeof TagDisposition[keyof typeof TagDisposition];
export const TagPlacement = Object.freeze({
TextNode: "TextNode",
Attribute: "Attribute",
} as const);
export type TagPlacement = typeof TagPlacement[keyof typeof TagPlacement];
export type Tag = TextNodeTag | AttributeTag;
export interface BaseTag {
name: string;
options?: IMap<any>;
/**
* The full tag text, for instance: "{#my-tag}".
*/
rawText: string;
disposition: TagDisposition;
}
export interface TextNodeTag extends BaseTag {
placement: typeof TagPlacement.TextNode;
xmlTextNode: XmlTextNode;
}
export interface AttributeTag extends BaseTag {
placement: typeof TagPlacement.Attribute;
xmlNode: XmlGeneralNode;
attributeName: string;
}