Sha256: a8f9690cea059fc70180312828f9b1f976b5aadddde2e137dee19ea5e54392e7
Contents?: true
Size: 796 Bytes
Versions: 8
Compression:
Stored size: 796 Bytes
Contents
module PDFEmbedder require 'pathname' class PDFTag < Liquid::Tag def initialize(tag_name, url, tokens) super @url = url end def render(context) # current directory filedir = File.dirname(context.registers[:page]["path"]) # if the path is relative than we have escape up one level if !Pathname.new(@url.strip).absolute? pdfpath = File.path(File.join("..", @url.strip)) else pdfpath = @url.strip end result = "<div class=\"pdf-wrapper\">" result += "<embed src=\"#{pdfpath}\"/>" result += "<div class=\"caption\">Original file: <a href=\"#{pdfpath}\">#{File.basename(pdfpath)}</a></div>" result += "</div>" end end end Liquid::Template.register_tag('embedpdf', PDFEmbedder::PDFTag)
Version data entries
8 entries across 8 versions & 1 rubygems