Class: JekyllGithubSample::CodeTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- JekyllGithubSample::CodeTag
show all
- Includes:
- TextUtils
- Defined in:
- lib/jekyll_github_sample/code_tag.rb
Constant Summary
Constants included
from TextUtils
TextUtils::INDEN_REGEX
Instance Method Summary
collapse
Methods included from TextUtils
#remove_common_indentation
Constructor Details
#initialize(tag_name, params, tokens) ⇒ 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
|