Example:
If I type “WorldCache” anywhere on my site, across all of the HTML pages, I’d like the site to automatically link the text to the home page of WorldCache without me ever having to manually input an ‘a’ tag.
The preferable way to do something like this would be to modify your content before it reaches your customer rather than using JavaScript on the client. For example, some customers may disable JavaScript.
Flask uses Jinja as it’s templating language - I bet you could use replace()and some of the other features of Jinja to achieve this on the server. If the content is static, pre-processing the html files before publishing would also make sense.
I went ahead and made a repl showing how you can use replacing to achieve link substitution with jinja filters. I’ve covered some of the drawbacks (chaining implications) and safety considerations. Let me know what you think:
This is a really bare-bones solution that doesn’t handle things such as, if you already had a tag that said WorldCache, or even just a big text element like this one saying it:
If you need me to write a more in-depth solution with the checking and stuff, I can.
And by the way as Sam said once again:
If this functionality is 100% necessary (if they have JS disabled, it just won’t do the links.), then you can make a <noscript> tag that you can make redirect to a JavaScript Disabled page. But there’s not a lot of people who disable their JS (especially since it’s crucial for many websites’ functionality), so you probably won’t need this and it would be fine to just have them not link