Sha256: 3f1ff85ef819fc7515aa41708317658c4e82fd0b1ed5b58e009a0d60dcb162e2
Contents?: true
Size: 886 Bytes
Versions: 16
Compression:
Stored size: 886 Bytes
Contents
# frozen_string_literal: true module DocTemplate module Tags class ImageTag < TableTag TAG_NAME = 'image' TEMPLATES = { default: 'image.html.erb', gdoc: 'gdoc/image.html.erb' }.freeze def parse_table(table) params = { caption: table.at_xpath('.//tr[2]/td').text, image_src: image_src, subject: @opts[:metadata].try(:[], 'subject') } @content = parse_template(params, template_name(@opts)) replace_tag table end private def image_src filename = "#{@opts[:value]}.jpg" grade = @opts[:metadata]['grade'] unit = @opts[:metadata]['unit'] "https://unbounded-uploads-development.s3.amazonaws.com/ela-images/G#{grade}/#{unit}/#{filename}" end end end Template.register_tag(Tags::ImageTag::TAG_NAME, Tags::ImageTag) end
Version data entries
16 entries across 16 versions & 1 rubygems