how do i get links in html and css to render references on a page?

A simple string substitution won’t work here, you will have to use an anchored regex. This means that you never match parts of a word, only whole words:

processed_body = processed_body.gsub(/\[email protected]#{mention.user.username}\b/, 
                                     "<a href='/user/#{}'>@#{mention.user.username}</a>")

Here we replaced the pattern string with a regex and used \b to anchor it to word boundaries.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top