Created
March 10, 2013 07:57
-
-
Save adammcarth/5127559 to your computer and use it in GitHub Desktop.
If statement inside an image_tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What I'm trying to achieve? | |
I want to have a left tooltip (tooltip-left) for the 2 results which display on the left hand side, and a right tooltip (tooltip-right) for the other 2 results which display on the right. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Without tooltip customisation | |
<%= link_to image_tag(image.path, :alt => image.description), "/images/" + image.permalink.to_s, "data-toggle" => "tooltip-left", "data-original-title" => image.tooltip %> | |
# With tooltip customisation | |
<%= link_to image_tag(image.path, :alt => image.description), "/images/" + image.permalink.to_s, "data-toggle" => "#{if index == 0 or index == 2}tooltip-left#{else}tooltip-right#{end}", "data-original-title" => image.tooltip %> | |
# Error output: | |
# syntax error, unexpected '}', expecting keyword_then or ';' or '\n' | |
# | |
# Any ideas as to how I could approach this problem? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment