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.



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

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 = sanitizeName(markups[0])
    @tab = markups[1]
end

Instance Method Details

#render(context) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/jekyll-tabs.rb', line 48

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



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

alias_method :render_block, :render