agentsclimarketplace

Svelte template directives

Skill spences10/skills/svelte-template-directives

Svelte template directive guidance. Use when working with snippets, attachments, dynamic HTML, declaration tags, debugging tags, or global DOM events.From its SKILL.md

Install
npx -y skills add spences10/skills --skill svelte-template-directives

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.9 KB, 647 tokens by cl100k_base, as published. Nobody here has run it

Svelte Template Directives

@attach (Svelte 5.29+)

The reactive alternative to use: actions. Re-runs when dependencies change, passes through components via spread, supports cleanup functions.

<script>
	import ImageZoom from 'js-image-zoom';

	function useZoom(options) {
		return (element) => {
			new ImageZoom(element, options);
			return () => console.log('cleanup');
		};
	}
</script>

<!-- Re-runs if options changes (use: wouldn't!) -->
<figure {@attach useZoom({ width: 400 })}>
	<img src="photo.jpg" alt="zoomable" />
</figure>

Quick Reference

DirectivePurposeReactive?
{@attach}DOM manipulation, 3rd-partyYes
{@html}Render raw HTML stringsYes
{@render}Render snippetsYes
{let ...} / {const ...}Local declarations in markupN/A
{@debug}Pause debugger on value changeN/A
{#each (key)}Keyed iteration (always key!)Yes
<svelte:window>Window event listenersN/A

@attach vs use: Actions

Featureuse:@attach
Re-runs on arg changeNoYes
ComposableLimitedFully
Pass through propsManualAuto via spread
Convert legacyN/AfromAction()

Reference Files

Notes

  • @attach requires Svelte 5.29+
  • Use fromAction from svelte/attachments to convert legacy actions
  • Attachments pass through wrapper components when you spread props
  • Always use keyed each blocks — never use index as key
  • Use <svelte:window>/<svelte:document> for global events, not $effect
  • Use {const ...} / {let ...} declaration tags for local markup variables; {@const ...} is legacy syntax.
  • Last verified: 2026-05-31
<!-- PROGRESSIVE DISCLOSURE GUIDELINES: - Keep this file ~50 lines total (max ~150 lines) - Use 1-2 code blocks only (recommend 1) - Keep description <200 chars for Level 1 efficiency - Move detailed docs to references/ for Level 3 loading - This is Level 2 - quick reference ONLY, not a manual -->

What ships with it: 2 files

11.6 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.