Class: Jekyll::RemoteIncludeTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll_remote_include.rb

Overview

Remotely fetch a markdown file.

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, text, tokens) ⇒ RemoteIncludeTag

Returns a new instance of RemoteIncludeTag.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll_remote_include.rb', line 7

def initialize(tag_name, text, tokens)
  super

  text.strip!
  check_protocol(text)
  uri = URI(text)

  check_extension(uri.path)

  res = Net::HTTP.get_response(uri)
  fail 'resource unavailable' unless res.is_a?(Net::HTTPSuccess)

  @content = res.body.force_encoding("UTF-8")
end

Instance Method Details

#render(_context) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/jekyll_remote_include.rb', line 22

def render(_context)
  # remove Title from readme (i.e. # Web SDK)
  @content = @content.gsub(/(^|\n)#\s.*/, '')

  # remove Doc Links from readme
  @content = @content.gsub(/.*check out moesif.*www\.moesif\.com.*to learn more.*/i, '')
  @content
end