insert_git_code.rb 458 B

123456789101112131415161718192021
  1. require 'open-uri'
  2. module Jekyll
  3. class InsertGitCode < Liquid::Tag
  4. def initialize(tag_name, url, tokens)
  5. super
  6. url = url.strip()
  7. @filename = File.basename(url)
  8. encoded_url = URI.encode(url)
  9. @file = URI.parse(encoded_url).read
  10. end
  11. def render(_context)
  12. @file
  13. end
  14. end
  15. end
  16. Liquid::Template.register_tag('insert_git_code', Jekyll::InsertGitCode)