Home / Function/ renderSlotToString() — astro Function Reference

renderSlotToString() — astro Function Reference

Architecture documentation for the renderSlotToString() function in slot.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  c7a8186f_aeaf_a5d7_bd00_b110613a15c0["renderSlotToString()"]
  c9adf848_436e_587f_c997_d91471df3357["slot.ts"]
  c7a8186f_aeaf_a5d7_bd00_b110613a15c0 -->|defined in| c9adf848_436e_587f_c997_d91471df3357
  96ef6c84_348c_217f_a781_262e9b1b107c["renderSlots()"]
  96ef6c84_348c_217f_a781_262e9b1b107c -->|calls| c7a8186f_aeaf_a5d7_bd00_b110613a15c0
  927068e0_2c28_7bc0_366c_08b94dfdfc57["mergeSlotInstructions()"]
  c7a8186f_aeaf_a5d7_bd00_b110613a15c0 -->|calls| 927068e0_2c28_7bc0_366c_08b94dfdfc57
  0af113ef_9488_b2d7_aea4_a88f43fa1bc8["renderSlot()"]
  c7a8186f_aeaf_a5d7_bd00_b110613a15c0 -->|calls| 0af113ef_9488_b2d7_aea4_a88f43fa1bc8
  style c7a8186f_aeaf_a5d7_bd00_b110613a15c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/runtime/server/render/slot.ts lines 60–87

export async function renderSlotToString(
	result: SSRResult,
	slotted: ComponentSlotValue | RenderTemplateResult,
	fallback?: ComponentSlotValue | RenderTemplateResult,
): Promise<string> {
	let content = '';
	let instructions: null | RenderInstruction[] = null;
	const temporaryDestination: RenderDestination = {
		write(chunk) {
			// if the chunk is already a SlotString, we concatenate
			if (chunk instanceof SlotString) {
				content += chunk;
				instructions = mergeSlotInstructions(instructions, chunk);
			} else if (chunk instanceof Response) return;
			else if (typeof chunk === 'object' && 'type' in chunk && typeof chunk.type === 'string') {
				if (instructions === null) {
					instructions = [];
				}
				instructions.push(chunk);
			} else {
				content += chunkToString(result, chunk);
			}
		},
	};
	const renderInstance = renderSlot(result, slotted, fallback);
	await renderInstance.render(temporaryDestination);
	return markHTMLString(new SlotString(content, instructions));
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does renderSlotToString() do?
renderSlotToString() is a function in the astro codebase, defined in packages/astro/src/runtime/server/render/slot.ts.
Where is renderSlotToString() defined?
renderSlotToString() is defined in packages/astro/src/runtime/server/render/slot.ts at line 60.
What does renderSlotToString() call?
renderSlotToString() calls 2 function(s): mergeSlotInstructions, renderSlot.
What calls renderSlotToString()?
renderSlotToString() is called by 1 function(s): renderSlots.

Analyze Your Own Codebase

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

Try Supermodel Free