Class: CS50::NextTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-theme-cs50.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, text, tokens) ⇒ NextTag

Returns a new instance of NextTag.


35
36
37
38
# File 'lib/jekyll-theme-cs50.rb', line 35

def initialize(tag_name, text, tokens)
  super
  @text = (text.length > 0) ? CGI.escapeHTML(text.strip().gsub(/\A"|"\Z/, "").gsub(/\A"|"\Z/, "")) : "Next"
end

Instance Method Details

#render(context) ⇒ Object


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

def render(context)
  site = context.registers[:site]
  converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
  button = Sanitize.fragment(converter.convert(@text), :elements => ["b", "code", "em", "i", "img", "span", "strong", "sub", "sup"])
  <<~EOT
    <button class="btn btn-dark btn-sm" data-next type="button">#{button}</button>
  EOT
end