Skip to content Skip to sidebar Skip to footer

Html&grails - Urls Text Is Not Displayed As Hyperlink

I have the following gsp code:

${direction?.description?.toHtml()?.decodeHTML()}

direction?.description is a text which the user entered in

Solution 1:

You have two way to do this.

Server side with a Grails taglib

You could create a custom Grails taglib that look for URLs in your text and replace with <a> tags when needed. It could be used like this:

<myTagLib:replaceUrls>${direction?.description}</myTagLib:replaceUrls>

Client side with javascript

You can use a javascript library to search URLs in strings and then auto replace them with the proper hyperlink. See this question for more information about this techinque.

Post a Comment for "Html&grails - Urls Text Is Not Displayed As Hyperlink"