Skip to content

Instantly share code, notes, and snippets.

@melborne
Created April 16, 2013 04:43
Show Gist options
  • Select an option

  • Save melborne/5393407 to your computer and use it in GitHub Desktop.

Select an option

Save melborne/5393407 to your computer and use it in GitHub Desktop.
Liquid gumroad tag for Jekyll
# encoding: UTF-8
# A Liquid tag for Jekyll sites that allows embedding Gumroad Overlay link.
# by: Kyo Endo
# Source URL: https://gist.github.com/
#
# Example usage: {% gumroad RjRO Title of Link %}
module Jekyll
class GumroadTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
end
def render(context)
url, title = @text.split(/\s/, 2).map(&:strip)
%{<a href="http://gum.co/#{url}" class="gumroad-button" id="#{url}">#{title}</a><script type="text/javascript" src="https://gumroad.com/js/gumroad-button.js"></script><script type="text/javascript" src="https://gumroad.com/js/gumroad.js"></script>}
end
end
end
Liquid::Template.register_tag('gumroad', Jekyll::GumroadTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment