Class: Jekyll::Spoiler::Block
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::Spoiler::Block
- Defined in:
- lib/jekyll-spoiler.rb
Instance Method Summary collapse
-
#initialize(tag_name, arguments, _tokens) ⇒ Block
constructor
A new instance of Block.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, arguments, _tokens) ⇒ Block
Returns a new instance of Block.
8 9 10 11 12 13 |
# File 'lib/jekyll-spoiler.rb', line 8 def initialize(tag_name, arguments, _tokens) super @args = parse_args(arguments) @title = @args['title'].nil? || @args['title'].empty? ? 'Spoiler' : @args['title'] end |
Instance Method Details
#render(context) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jekyll-spoiler.rb', line 15 def render(context) content = Kramdown::Document.new(super).to_html # rubocop:disable Layout/ArrayAlignment return %W[ <details class="spoiler"> <summary class="spoiler-title">#{@title}</summary> #{content.strip} </details> ].join(' ') # rubocop:enable Layout/ArrayAlignment end |