Skip to main content
0 online
monster Aug 1, 2006

I don't think I am doing anything different... Do we need to code the web addresses to be hyperlinks?

iwz Aug 1, 2006

yeah, i haven't added in a parser yet, so if you want to make a link, use HTML <a href="http://whatever">click here linky link</a>

deanh77 Aug 15, 2006

no need for a parser. rails has a method "linkify" so like: <%= linkify comment.text %> instead of <%= comment.text %>

iwz Aug 15, 2006

ah! that's nice. that's a great quick fix. i'll get it in ASAP. i've been looking into implementing RedCloth or BlueCloth. their markup languages seem pretty nice. ideally, i'd like to get th...

deanh77 deanh77Founder ·

apparently I just imagined this method, I can't seem to find it anywhere. weird....

M
monsterEst. 2006 ·

hmmm... looks like it should be there...

Contrast this to the way Ruby on Rails handles templating logic. In essence, it /does/ have a templating language - it just so happens that this language is Ruby as well. What's really smart is that Rails makes use of Ruby's syntactic flexibility to create a domain specific language (or mini language) adapted to the needs of templates. Built in functions are provided like h() (for HTML escaping) and linkify() (for auto-marking-up links). Because Ruby lets you omit parentheses, you end up with template code looking like this:

http://radar.oreilly.com/archives/2005/06/ruby_on_rails_a.html

deanh77 deanh77Founder ·

OK! I found it: (it's automatically available to you within a rails RHTML file, this is found in text_helper.rb)

# Turns all urls and email addresses into clickable links. The +link+ parameter can limit what should be linked.
# Options are :all (default), :email_addresses, and :urls.
#
# Example:
# auto_link("Go to http://www.rubyonrails.com and say hello to david@loudthinking.com") =>
# Go to http://www.rubyonrails.com and
# say hello to david@loudthinking.com
#
# If a block is given, each url and email address is yielded and the
# result is used as the link text. Example:
# auto_link(post.body, :all, :target => '_blank') do |text|
# truncate(text, 15)
# end
def auto_link(text, link = :all, href_options = {}, &block)
return '' if text.blank?
case link
when :all then auto_link_urls(auto_link_email_addresses(text, &block), href_options, &block)
when :email_addresses then auto_link_email_addresses(text, &block)
when :urls then auto_link_urls(text, href_options, &block)
end
end

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.