开发者

RoR - make links clickable that show up in a user comment

开发者 https://www.devze.com 2022-12-11 08:45 出处:网络
I am looking for a Ruby开发者_StackOverflow script that takes a piece of text, and makes any links click-able that show up in it... Does anyone have something like this? For example, if I wrotea comme

I am looking for a Ruby开发者_StackOverflow script that takes a piece of text, and makes any links click-able that show up in it... Does anyone have something like this? For example, if I wrote a comment and said "Come check out my site at http://www.example.com", then the link would be click-able like an html tag.

Thanks,

Josh


Rails has a View helper called auto_link, e.g.:

<%= auto_link("Please visit my site: http://www.example.org/") %>

would produce:

Please visit my site: <a href="http://www.example.org/">http://www.example.org/</a>

Update: You can find more information about it here.

0

精彩评论

暂无评论...
验证码 换一张
取 消