svelte-ast-print
Version:
Serialize Svelte AST nodes into stringified syntax. A.k.a parse in reverse.
59 lines • 1.91 kB
JavaScript
/**
* Printers related to Svelte **template**-related AST nodes only.
* @module svelte-ast-print/template
*/
import { printAttributeLike } from "./template/attribute-like.js";
import { printBlock } from "./template/block.js";
import { printElementLike } from "./template/element-like.js";
import { printHTMLNode } from "./template/html.js";
import { printRoot } from "./template/root.js";
import { printTag } from "./template/tag.js";
/**
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export function printTemplateNode(n, opts = {}) {
// biome-ignore format: Prettier
// prettier-ignore
switch (n.type) {
case "Attribute":
case "SpreadAttribute":
case "AnimateDirective":
case "BindDirective":
case "ClassDirective":
case "LetDirective":
case "OnDirective":
case "StyleDirective":
case "TransitionDirective":
case "UseDirective": return printAttributeLike(n, opts);
case "AwaitBlock":
case "KeyBlock":
case "EachBlock":
case "IfBlock":
case "SnippetBlock": return printBlock(n, opts);
case "Component":
case "RegularElement":
case "SlotElement":
case "SvelteBody":
case "SvelteBoundary":
case "SvelteComponent":
case "SvelteDocument":
case "SvelteElement":
case "SvelteFragment":
case "SvelteHead":
case "SvelteOptions":
case "SvelteSelf":
case "SvelteWindow":
case "TitleElement": return printElementLike(n, opts);
case "AttachTag":
case "ConstTag":
case "DebugTag":
case "ExpressionTag":
case "HtmlTag":
case "RenderTag": return printTag(n, opts);
case "Comment":
case "Text": return printHTMLNode(n, opts);
case "Root": return printRoot(n, opts);
}
}
//# sourceMappingURL=template.js.map