class CS50::AlertBlock
Public Class Methods
new(tag_name, text, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll-theme-cs50.rb, line 12 def initialize(tag_name, text, tokens) super alert = text.strip().gsub(/\A"|"\Z/, "").gsub(/\A"|"\Z/, "") @alert = (["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"].include? alert) ? alert : "" end
Public Instance Methods
render(context)
click to toggle source
Calls superclass method
# File lib/jekyll-theme-cs50.rb, line 18 def render(context) site = context.registers[:site] converter = site.find_converter_instance(::Jekyll::Converters::Markdown) message = converter.convert(super(context)) <<~EOT <div class="alert" data-alert="#{@alert}" role="alert"> #{message} </div> EOT end