Project

smartlinks

0.0
No commit activity in last 3 years
No release in over 3 years
Gem for linkfying your text
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

SmartLinks

Gem for linkifying text

Installation

Just as usual. If you're using bundler - just this to your Gemfile:

gem 'smartlinks'

And then execute:

bundle install

Or install it yourself:

gem install smartlinks

Usage

This gem is very simple. You have only one method, that you need. For example:

    text = "@sqrel and @troyanryller just made a cool gem!"

    Smartlinks.linkify text

That's it! Now you have linkified text:

<a href="https://twitter.com/sqrel">@sqrel</a> and <a href="https://twitter.com/troyanryller">@troyanryller</a> just made a cool gem!

By default, gem interprets @user and #hash as twitter user and hashtag, but you can explicitly define domain to user and hashtag:

Smartlinks.linkify text, account: "http://example.com/%s", hashtag: "http://example.com/search/%s"

%s will be replaced to username or hash

Also you can define additional links params, for example:

Smartlinks.linkify text, params: { class: "some-link-class", rel: "nofollow" }

Credits