I have a question regarding link_to helpers. When do you use them and when do you not use them.
Example.
Use basic HTML:
FooBaror instead use a helper:
Both return the same result. Is it strictly a preference? I find the syntax of these helpers so forgettable and non-intuitive. I'm not the smartest kid in the class, but every time I need to add a class name to the link so that the CSS style takes affect, I find myself googling "How do I add class names to link_to calls". It's a pain. It's my pain, but it's a pain.
Also, what about link_to_remote? What if I have a loop in my view and I'm outputting 10 or 20 list items that each have the link_to_remote call? Do I really want the JS function created 20 times? 1 for each call?
Obviously DHH and his crew of merry men have a reason and a purpose for these helpers, otherwise they wouldn't be there, or at least they wouldn't be called helpers, they'd be called annoyers, but somewhere in our web apps we're going to have to write some HTML code. Or is there a create_linebreak_here helper that inserts a <br /> for you?
What is the best practice when it comes to these little do-dads?
Resource Links:
Leave a comment