Created
April 16, 2013 04:43
-
-
Save melborne/5393407 to your computer and use it in GitHub Desktop.
Liquid gumroad tag for Jekyll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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