Sha256: 542e53d83b35de571625c36851fecbd417b1a8d039845998c3dba2facf055ca1
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
# encoding: utf-8 module Middleman module Presentation # Helper module module Helpers # Images helpers module Images # 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? Middleman::Presentation.t('errors.asset_not_found', asset: substring) else result.relative_path_from(Pathname.new(source_dir)).to_s end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
middleman-presentation-helpers-0.0.3 | lib/middleman-presentation/helpers/images.rb |
middleman-presentation-helpers-0.0.2 | lib/middleman/presentation/helpers/images.rb |