Render snippet as string. Access snippet value passed to a component (render.raw) #13558
fabiogiolito
started this conversation in
Ideas
Replies: 1 comment
-
There is no raw code at runtime, it all gets compiled down to optimized SSR or CSR code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
If your component takes a snippet
foo
, the value passed in doesn't seem to be accessible to the component.The only option is to
{@render foo(options)}
which makes Svelte interpret and mount the code.It would be great if there was a way to access the raw code of the snippet, whatever was passed in, as a string.
Eg:
foo(options).raw
or{@render.raw foo(options)}
.Use case example
A
<ComponentPreview />
component used in documentation, that renders a given component and displays the code of how to use the component. I have to pass the same code twice, once as a string for displaying with syntax highlighting and once as the child so it can be rendered and displayed.This duplication could be avoided if
<ComponentPreview />
could access thechildren()
snippet's raw value.Beta Was this translation helpful? Give feedback.
All reactions