Add insert_git_code plugin
This commit is contained in:
21
blog.bryanroessler.com/_plugins/insert_git_code.rb
Normal file
21
blog.bryanroessler.com/_plugins/insert_git_code.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
require 'open-uri'
|
||||||
|
|
||||||
|
module Jekyll
|
||||||
|
class InsertGitCode < Liquid::Tag
|
||||||
|
|
||||||
|
def initialize(tag_name, url, tokens)
|
||||||
|
super
|
||||||
|
url = url.strip()
|
||||||
|
@filename = File.basename(url)
|
||||||
|
encoded_url = URI.encode(url)
|
||||||
|
@file = URI.parse(encoded_url).read
|
||||||
|
end
|
||||||
|
|
||||||
|
def render(_context)
|
||||||
|
@file
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Liquid::Template.register_tag('insert_git_code', Jekyll::InsertGitCode)
|
||||||
Reference in New Issue
Block a user