svelte-ast-print
Version:
Serialize Svelte AST nodes into stringified syntax. A.k.a parse in reverse.
139 lines • 3.32 kB
TypeScript
/**
* Printers related to Svelte **block**-related AST nodes only.
* @module svelte-ast-print/template/block
*/
import type { AST as SV } from "svelte/compiler";
import type { PrintOptions } from "../_internal/option.js";
import { type Result } from "../_internal/shared.js";
/**
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export declare function printBlock(n: SV.Block, opts?: Partial<PrintOptions>): Result<SV.Block>;
/**
* @see {@link https://svelte.dev/docs/svelte/await}
*
* @example standard
* ```svelte
* {#await expression}...{:then name}...{:catch name}...{/await}
* ```
*
* @example without catch
* ```svelte
* {#if expression}...{:else if expression}...{/if}
* ```
*
* @example without pending body
* ```svelte
* {#await expression then name}...{/await}
* ```
*
* @example with catch body only
* ```svelte
* {#await expression catch name}...{/await}
* ```
*
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export declare function printAwaitBlock(n: SV.AwaitBlock, opts?: Partial<PrintOptions>): Result<SV.AwaitBlock>;
/**
* @see {@link https://svelte.dev/docs/svelte/each}
*
* @example simple
* ```svelte
* {#each expression as name}...{/each}
* ```
*
* @example without "as" item
* ```svelte
* {#each expression}...{/each}
* ```
*
* @example without "as" item, but with index
* ```svelte
* {#each expression, index}...{/each}
* ```
*
* @example with index
* ```svelte
* {#each expression as name, index}...{/each}
* ```
*
* @example keyed
* ```svelte
* {#each expression as name (key)}...{/each}
* ```
*
* @example with index and keyed
* ```svelte
* {#each expression as name, index (key)}...{/each}
* ```
*
* @example with else clause for when list is empty
* ```svelte
* {#each expression as name}...{:else}...{/each}
* ```
*
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export declare function printEachBlock(n: SV.EachBlock, opts?: Partial<PrintOptions>): Result<SV.EachBlock>;
/**
* @see {@link https://svelte.dev/docs/svelte/if}
*
* @example simple
* ```svelte
* {#if expression}...{/if}
* ```
*
* @example with else if
* ```svelte
* {#if expression}...{:else if expression}...{/if}
* ```
*
* @example with else
* ```svelte
* {#if expression}...{:else}...{/if}
* ```
*
* @example with else if and else
* ```svelte
* {#if expression}...{:else if expression}...{:else}...{/if}
* ```
*
* @example with multiple else if and else
* ```svelte
* {#if expression}...{:else if expression}...{:else if expression}...{:else}...{/if}
* ```
*
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export declare function printIfBlock(n: SV.IfBlock, opts?: Partial<PrintOptions>): Result<SV.IfBlock>;
/**
* @see {@link https://svelte.dev/docs/svelte/key}
*
* @example pattern
* ```svelte
* {#key expression}...{/key}
* ```
*
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export declare function printKeyBlock(n: SV.KeyBlock, opts?: Partial<PrintOptions>): Result<SV.KeyBlock>;
/**
*
* @see {@link https://svelte.dev/docs/svelte/snippet}
*
* @example pattern
* ```svelte
* {#snippet expression(parameters)}...{/snippet}
* ```
*
* @since 1.0.0
* @__NO_SIDE_EFFECTS__
*/
export declare function printSnippetBlock(n: SV.SnippetBlock, opts?: Partial<PrintOptions>): Result<SV.SnippetBlock>;
//# sourceMappingURL=block.d.ts.map