Class: JekyllGithubSample::CodeTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- JekyllGithubSample::CodeTag
- Includes:
- TextUtils
- Defined in:
- lib/jekyll_github_sample/code_tag.rb
Direct Known Subclasses
Constant Summary
Constants included from TextUtils
Instance Method Summary collapse
-
#initialize(tag_name, params, tokens) ⇒ CodeTag
constructor
A new instance of CodeTag.
- #render(context) ⇒ Object
Methods included from TextUtils
Constructor Details
#initialize(tag_name, params, tokens) ⇒ CodeTag
Returns a new instance of CodeTag.
11 12 13 14 15 16 |
# File 'lib/jekyll_github_sample/code_tag.rb', line 11 def initialize(tag_name, params, tokens) github_file_path, @line_start, @line_end = params.split @github_file = FileHelper.new(github_file_path) @line_start, @line_end = determine_line_numbers(@line_start, @line_end) super end |
Instance Method Details
#render(context) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/jekyll_github_sample/code_tag.rb', line 18 def render(context) all_lines = cache.fetch(@github_file.raw_uri) do open(@github_file.raw_uri).readlines end lines = all_lines[@line_start..@line_end] lines = remove_common_indentation(lines) lines.join end |