Home / Function/ SnippetBlock() — svelte Function Reference

SnippetBlock() — svelte Function Reference

Architecture documentation for the SnippetBlock() function in SnippetBlock.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  733f3c39_285b_ebf1_f67f_3dc2ece5eaa4["SnippetBlock()"]
  4017addc_67a0_74ad_63c4_cd8e00ec8c49["SnippetBlock.js"]
  733f3c39_285b_ebf1_f67f_3dc2ece5eaa4 -->|defined in| 4017addc_67a0_74ad_63c4_cd8e00ec8c49
  style 733f3c39_285b_ebf1_f67f_3dc2ece5eaa4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js lines 11–29

export function SnippetBlock(node, context) {
	let fn = b.function_declaration(
		node.expression,
		[b.id('$$renderer'), ...node.parameters],
		/** @type {BlockStatement} */ (context.visit(node.body))
	);

	// @ts-expect-error - TODO remove this hack once $$render_inner for legacy bindings is gone
	fn.___snippet = true;

	const statements = node.metadata.can_hoist ? context.state.hoisted : context.state.init;

	if (dev) {
		fn.body.body.unshift(b.stmt(b.call('$.validate_snippet_args', b.id('$$renderer'))));
		statements.push(b.stmt(b.call('$.prevent_snippet_stringification', fn.id)));
	}

	statements.push(fn);
}

Domain

Subdomains

Frequently Asked Questions

What does SnippetBlock() do?
SnippetBlock() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js.
Where is SnippetBlock() defined?
SnippetBlock() is defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js at line 11.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free