Notes posted by tordans
RSS feedactive_link_to helper gem
You should also have a look at github.com/twg/active_link_to if you need an ‘active’ class on your links.
New Website for RedCloth
The Link above doesnt work anymore. This one should be the new one: http://redcloth.org/
Nice german translation independet of structure of a sentence
Eine pragmatische Lösung für das Übersetzungsproblem der Rails Methode distance_of_time_in_words(). Im Deutschen wird je nach Satzbau eine andere Ausgabe benötigt.
Vor mehr als 5 Monaten“/”Vor etwa einem Jahr“ — statt wie im Original ”Dauer: mehr als 5 Monate“/”Dauer: etwa 1 Jahr
How to check if a Yield has content?
How do I do this without actually calling the yield?
- if yield :footer = yield :footer - else = render "layouts/footer_big"
(Note: HAML Syntax) Thanks.
How to use with HAML
Are you using HAML and try to do the block-thing (do…)? Please note that the whole block has to be in a single line. More: http://groups.google.com/group/haml/browse_thread/thread/52e62ef501c504a3
Shortcut with %
Thanks iamcata, that works :). And I finally found the right place to put this comment: http://apidock.com/ruby/String/%25#726-Use-it-with-HAML
Use it with HAML
Like Henrik pointed out <a href=“http://henrik.nyh.se/2008/01/surround-helper-alternative-in-haml”>in his blogpost, this method is particulary useful when using HAML (http://haml-lang.com/) in Rails.
Instead of usind the HAML-Helper ‘surround’ (etc) you can just write
= "(%s)" % link_to("Edit", ...)
Or with two Arguments:
= "(%s, %s)" % ["Edit", "Delete"]
Thanks very much, Henrik!
Shortcut
According to http://henrik.nyh.se/2008/01/surround-helper-alternative-in-haml there is a short version for sprintf:
“(%s)” % “foo” is the same as sprintf(“(%s)”, “foo”)
Can someone who knows write more about this here? How do I work with multiple strings? Is this even possible? “(%s %t)” % “foo”, “bar” does not work.