Parse plain text and connect its parts to svelte
See original GitHub issueHello
What i’m writing about is very common scenario in today’s web programming - namely hashtags and user mentions. User writes tags in plain text post and its saved on server:
{content:" text text #Cup "}
When retrieving from server those hashtags needs to be clickable. Problem is that changing “#Cup” into link or <Link> element makes it just plain text element
<script>
import { link } from "svelte-routing"
function hash(text) {
return text.replace(/\#Cup/, '<a href="cup" use:link>Cup</a>')
}
</script>
<p>
{hash("this is a #Cup")} //this returns plain text
</p>
<p>
{@html hash("this is a #Cup")} //this returns plain html
</p>
So what is the way to make svelte to understand that use:link
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Bindings / Text inputs • Svelte Tutorial
As a general rule, data flow in Svelte is top down — a parent component can set props on a child component, and...
Read more >Dynamic behavior in Svelte: working with variables and props
In this case Svelte is using the export keyword to mark a variable declaration as a property or prop, which means it becomes...
Read more >Provide non-decoded text to parse consumers #2714 - GitHub
Currently, parse from svelte/compiler decodes HTML entities (such as & or ˙ ). This causes tools like prettier-plugin-svelte that ...
Read more >How to Fetch Data in Svelte - SitePoint
Learn how to consume a REST API using the Fetch API vs the Axios client. ... As you can see, the component contains...
Read more >Rendering Svelte components from HTML string
As you say though, you could do something very similar by compiling <MyComponent> to a custom element called <my-component> instead, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Like this? https://stackoverflow.com/questions/62487278/parse-fetched-hashtags-and-create-svelte-routing-links
Then please try stackoverflow under the Svelte tag. Github issues is designed for bugs and feature requests for Svelte, and is not suitable for support.