Sha256: 17533e47f7cb1a02a905bf32e6db6a47e9b7d9851309e65f241cadb55891de7e

Contents?: true

Size: 807 Bytes

Versions: 2

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

require_relative 'div_tag'

module Jekyll
  class AlertBlock < DivTag
    def initialize(tag_name, markup, tokens)
      @alert_type = tag_name.split('_').first
      super tag_name, markup + ' alert alert-' + @alert_type, tokens
    end

    def tag
      'div'
    end

    HEADER = { 'info'    => 'Note',
               'warning' => 'Warning',
               'danger'  => 'Danger' }

    def render_content(context, content)
      super context, "**#{HEADER[@alert_type]}** \n" + content
    end
  end
end

Liquid::Template.register_tag('info_block', Jekyll::AlertBlock)
Liquid::Template.register_tag('warning_block', Jekyll::AlertBlock)
Liquid::Template.register_tag('danger_block', Jekyll::AlertBlock)
# Liquid::Template.register_tag('success_block', Jekyll::AlertBlock)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dynflow-1.9.0 doc/pages/plugins/alert_block.rb
dynflow-1.8.3 doc/pages/plugins/alert_block.rb