Class: JekyllGithubContent::GithubContentRenderer
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- JekyllGithubContent::GithubContentRenderer
- Defined in:
- lib/jekyll_github_content.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(tag_name, params, tokens) ⇒ GithubContentRenderer
constructor
A new instance of GithubContentRenderer.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, params, tokens) ⇒ GithubContentRenderer
Returns a new instance of GithubContentRenderer.
39 40 41 42 43 44 |
# File 'lib/jekyll_github_content.rb', line 39 def initialize(tag_name, params, tokens) path, @initial_line, @end_line = params.split @github_file = GithubUriParser.new(path) @initial_line, @end_line = parse_line_boundaries(@initial_line, @end_line) super end |
Instance Method Details
#render(context) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/jekyll_github_content.rb', line 46 def render(context) file_lines = cache.fetch(@github_file.get_raw_file_uri) do URI.open(@github_file.get_raw_file_uri).readlines end lines_to_print = file_lines[@initial_line..@end_line] lines_to_print.join end |