summaryrefslogblamecommitdiffstats
path: root/blog/_plugins/tracklist.rb
blob: afbc469aa0915baea763e1a5a7b6137f0168bffd (plain) (tree)





















































                                                                            
# Tags for helping with track lists
#
module Jekyll
  class BeginTrackListTag < Liquid::Tag
    def initialize(tag, text, tokens)
      super
    end

    def render(context)
      %q{<div class="track-list"><h2>Track list:</h2>}
    end
  end

  class EndTrackListTag < Liquid::Tag
    def initialize(tag, text, tokens)
      super
    end

    def render(context)
      %q{</div>}
    end
  end

  class TrackTag < Liquid::Tag
    def initialize(tag, text, tokens)
      super
      @num, @artist, @title, @url = text.split('|')
    end

    def render(context)
      %Q{<article class="track"><header>
        <span class="track-num">#{@num}</span> -
        <span class="track-artist"><a href="#{@url}">#{@artist}</a></span> -
        <span class="track-title">#{@title}</span></header>
        <section class="track-info">
      }
    end
  end

  class EndTrackTag < Liquid::Tag
    def initialize(tag, text, tokens)
      super
    end

    def render(context)
      %Q{</section></article>}
    end
  end
end

Liquid::Template.register_tag('begin_track_list', Jekyll::BeginTrackListTag)
Liquid::Template.register_tag('end_track_list', Jekyll::EndTrackListTag)
Liquid::Template.register_tag('track', Jekyll::TrackTag)
Liquid::Template.register_tag('end_track', Jekyll::EndTrackTag)