class Jekyll::Block::BlockTag
A Jekyll
Liquid {% block %} block tag that generates HTML for block-styled content. The content of the block can contain Markdown, which will be parsed by kramdown.
Usage:
{% block <type> ["Title"] %} *Markdown content* {% endblock %}
The type argument is mandatory, and the title is optional.
Attributes
id[R]
title[R]
type[R]
Public Class Methods
new(tag_name, text, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-block/block_tag.rb, line 17 def initialize(tag_name, text, tokens) @type, @title = text.match(%r!\s*(\w+)\s+(?:\"(.*)\".*)?!im).captures @id = @title ? @type.downcase + ":" + Jekyll::Utils.slugify(@title) : nil super end
Public Instance Methods
render(context)
click to toggle source
Calls superclass method
# File lib/jekyll-block/block_tag.rb, line 25 def render(context) text = super if @title "<div class=\"block #{@type}\" id=\"#{@id}\" markdown=\"block\">"\ "<a class=\"header\" href=\"##{id}\">"\ "#{@type.capitalize}: #{@title}"\ "</a>"\ "\n#{text}\n"\ "</div>" else "<div class=\"block #{@type}\" markdown=\"block\">"\ "<span class=\"header\">#{@type.capitalize}</span>"\ "\n#{text}\n"\ "</div>" end end