Sha256: d89ba35f6734bdeeab7da09c53eee5ca3730ccd7052a6580e0fb796171a5b1a3
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
# encoding: utf-8 module Middleman module Presentation # Helper module module Helpers # Create image gallery def image_gallery(images, image_gallery_id:) template = <<-EOS.strip_heredoc.chomp <a href="<%= image_path %>" data-lightbox="<%= image_gallery_id %>"> <img src="<%= image_path %>"<% if title %> alt="<%= title %>"<% end %> class="mp-preview-image"> </a> EOS images.each_with_object([]) do |(image, title), memo| engine = Erubis::Eruby.new(template) memo << engine.result(image_path: image, image_gallery_id: image_gallery_id, title: title) end.join("\n") end # Create entry for single image def image(image) image_gallery Array(image), image_gallery_id: SecureRandom.hex end # Find asset for substring def find_asset(substring) # sprockets.each_logical_path.find { |f| f.to_s.include? substring } result = sprockets.each_file.find { |f| f.to_s.include? substring } if result.blank? I18n.t('errors.asset_not_found', asset: substring) else result.relative_path_from(Pathname.new(source_dir)).to_s end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems