I’m creating a site using a small Ruby framework, Sinatra, but I would like to be able to do something like what the Rails link_to_unless_current method does, without using Rails.
Now I have my own link_to method, which works the same as the Rails one, more or less, so how would I go about doing the _unless_current part?
Seeing as how you mentioned your
link_tomethod is similar to the Rails one, give this a try:I gave this a quick test and worked perfectly for me, however if your
link_tomethod takes more parameters, it’s pretty simple to add more, just add them to the_unless_current(text, location, param1, param2, etc)and thelink_to text, location, param1, param2, etcparts of the code.