summaryrefslogtreecommitdiff
path: root/packages/astro-parser/src/parse/utils/node.ts
blob: 45769f96ec2b65c1c17ada91eb6a288d28a20ff4 (plain) (blame)
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
import { TemplateNode } from '../../interfaces.js';

export function to_string(node: TemplateNode) {
  switch (node.type) {
    case 'IfBlock':
      return '{#if} block';
    case 'ThenBlock':
      return '{:then} block';
    case 'ElseBlock':
      return '{:else} block';
    case 'PendingBlock':
    case 'AwaitBlock':
      return '{#await} block';
    case 'CatchBlock':
      return '{:catch} block';
    case 'EachBlock':
      return '{#each} block';
    case 'RawMustacheTag':
      return '{@html} block';
    case 'DebugTag':
      return '{@debug} block';
    case 'Element':
    case 'InlineComponent':
    case 'Slot':
    case 'Title':
      return `<${node.name}> tag`;
    default:
      return node.type;
  }
}