createRawSnippet() function creates a snippet programmatically from a render function. This is useful for library authors or when you need to generate snippets dynamically.
Import
Signature
Parameters
A function that receives the snippet parameters and returns an object with
render and optional setup methodsReturns
A snippet that can be rendered with
{@render}Usage
Basic snippet
With parameters
With setup and cleanup
Dynamic rendering
Library wrapper
Notes
- The
renderfunction is called every time the snippet is rendered - The
setupfunction is called once after the HTML is inserted into the DOM - HTML is inserted as raw HTML (not sanitized)
- Use with caution - improper use can lead to XSS vulnerabilities
- Primarily intended for library authors and advanced use cases
- Regular snippets (
{#snippet}) are preferred for normal application code