Skip to content

Instantly share code, notes, and snippets.

@takuyan
Last active December 24, 2015 01:39
Show Gist options
  • Save takuyan/6724903 to your computer and use it in GitHub Desktop.
Save takuyan/6724903 to your computer and use it in GitHub Desktop.
# # if Zero
# = switch_if(0) do
# h1
# ...
# # => <div class='zero' id='zero'><h1>...</h1></div>
#
# # if One
# = switch_if(1) do
# h1
# ...
# # => <div class='one' id='one'><h1>...</h1></div>
#
module HogeHelper
def switch_if(num)
if num == 0
content_tag :div, class: 'zero', id: 'zero' do
yield
end
elsif num == 1
content_tag :div, class: 'one', id: 'one' do
yield
end
else
content_tag :div do
yield
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment