[ANN] link_to_magic

Posted by pratik
on Monday, July 02

Sorry for the lame name. I was gonna name it link_to_sexy initially, but changed my mind at the last moment ;-)

This plugin is inspired from Josh Peek’s stringgable_shortcuts & Geoff Buesing’s patch

To install :

script/plugin install http://linktomagic.googlecode.com/svn/link_to_magic/

To use :

1.

<%= link_to @person %>

This is short for doing <%= link_to h(@person.name), @person %>. Here, a littile bit of ActiveRecord::Base.to_s magic is involved too. Check out this pastie to understand what/how it does this.

2.

<%= link_to_something @person %>

This is short for doing <%= link_to h(@person.something), @person %>.

Comments/suggestions welcome!

Comments

Leave a response

  1. AlexJuly 02, 2007 @ 09:37 PM

    This is really cool. Makes my markup a lot easier. It also makes sure I don’t slip up and forget to escape any link text.

    One feature I would enjoy having would be the ability to mimic named routes, e.g.

    <%= link_to_edit @person %> being equal to: <%= link_to h(@person.name), edit_person_path(@person)%>

    Anyway, great work ;)

    Alex

  2. inheritJuly 03, 2007 @ 10:48 AM

    wow,cool!

  3. matthibcnJuly 03, 2007 @ 07:30 PM

    Please make this site readable.

    Grey on black is a pain in the ass and cant be read..

    Thanks

    matthibcn