Class: Jekyll::CodeExampleTags::CodeExampleTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/pulsar-jekyll-code-example.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, example_string, tokens) ⇒ CodeExampleTag

Returns a new instance of CodeExampleTag.



85
86
87
88
# File 'lib/pulsar-jekyll-code-example.rb', line 85

def initialize(tag_name, example_string, tokens)
  @context_path, @example_name = Jekyll::CodeExampleTags::get_example_name_and_context(example_string) 
  super
end

Instance Method Details

#render(context) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/pulsar-jekyll-code-example.rb', line 90

def render(context)

  examples = Jekyll::CodeExampleTags::code_examples(@context_path, @example_name, context['site'])

  # Build the code example elements
  output = Jekyll::CodeExampleTags::buttons_markup(examples, context)
  examples.each do |lang, path|
    example_content = File.read(path)
    output << Jekyll::CodeExampleTags::example_markup(lang, example_content)
  end

  output = Jekyll::CodeExampleTags::wrap_examples_div(output)
end