Class: Jekyll::Tabs::TabBlock

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/jekyll-tabs.rb

Instance Method Summary collapse

Constructor Details

#initialize(block_name, markup, tokens) ⇒ TabBlock

Returns a new instance of TabBlock.



30
31
32
33
34
35
36
37
38
# File 'lib/jekyll-tabs.rb', line 30

def initialize(block_name, markup, tokens)
    super
    markups = markup.split(' ', 2)
    if markups.length != 2
        raise SyntaxError.new("Block #{block_name} requires 2 attributes")
    end
    @name = markups[0]
    @tab = markups[1]
end

Instance Method Details

#render(context) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/jekyll-tabs.rb', line 40

def render(context)
    site = context.registers[:site]
    converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
    environment = context.environments.first
    environment["tabs-#{@name}"] ||= {}
    environment["tabs-#{@name}"][@tab] = converter.convert(render_block(context))
end

#render_blockObject



28
# File 'lib/jekyll-tabs.rb', line 28

alias_method :render_block, :render