Loading...
Loading...
Svelte template directives ({@attach}, {@html}, {@render}, {@const}, {@debug}). Use for DOM manipulation, third-party libs, tooltips, canvas, dynamic HTML. @attach replaces use: actions.
npx skill4agent add spences10/svelte-skills-kit svelte-template-directivesuse:<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>| Directive | Purpose | Reactive? |
|---|---|---|
| DOM manipulation, 3rd-party | Yes |
| Render raw HTML strings | Yes |
| Render snippets | Yes |
| Local constants in blocks | N/A |
| Pause debugger on value change | N/A |
| Keyed iteration (always key!) | Yes |
| Window event listeners | N/A |
| Feature | | |
|---|---|---|
| Re-runs on arg change | No | Yes |
| Composable | Limited | Fully |
| Pass through props | Manual | Auto via spread |
| Convert legacy | N/A | |
@attachfromActionsvelte/attachments<svelte:window><svelte:document>$effect