I don't think I am doing anything different...
Do we need to code the web addresses to be hyperlinks?
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>
Tenjewberrymuds
Dude you said parser. Parsy parser, oooo I love parsing
no need for a parser.
rails has a method "linkify"
so like:
<%= linkify comment.text %>
instead of
<%= comment.text %>
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 the old tags working again, of course.
apparently I just imagined this method, I can't seem to find it anywhere. weird....
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
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