Skip to content

Instantly share code, notes, and snippets.

@sebjacobs
Created November 6, 2012 14:29
Show Gist options
  • Save sebjacobs/4025024 to your computer and use it in GitHub Desktop.
Save sebjacobs/4025024 to your computer and use it in GitHub Desktop.
AssetHelper
module AssetHelper
def figure_tag(content_type, content_urls=[], caption, options={})
case content_type
when :image
content = image_tag(content_urls.first, srcset: content_urls.join(','), alt: options[:alt])
when :video
content = video_tag(content_urls.first, alt: options[:alt], controls: true)
end
content += content_tag(:figcaption, caption)
content_tag :figure, content
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment