/ _plugins / epigraph.rb
epigraph.rb
 1  ## Liquid tag 'epigraph' used to add an epigraph
 2  ## in the main text area of the layout
 3  ## Usage {% epigraph 'text-body-of-epigraph' 'author-of-epigraph' 'citation-of-epigraph' %}
 4  #
 5  module Jekyll
 6    class RenderEpigraphTag < Liquid::Tag
 7  
 8    	require "shellwords"
 9  
10      def initialize(tag_name, text, tokens)
11        super
12        @text = text.shellsplit
13      end
14  
15      def render(context)
16          "<div class='epigraph'><blockquote><p>#{@text[0]}</p>"+
17          "<footer>#{@text[1]}, "+"<cite>#{@text[2]}</cite></footer></blockquote></div>"
18      end
19    end
20  end
21  
22  Liquid::Template.register_tag('epigraph', Jekyll::RenderEpigraphTag)