Class: PreTag::PreTagBlock
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- PreTag::PreTagBlock
- Defined in:
- pre.rb
Overview
""" {% pre %} Content here {% endpre %}
{% pre copyButton %} Content here {% endpre %}"""
Constant Summary collapse
- @@prefix =
"<button class='copyBtn' data-clipboard-target="
- @@suffix =
" title='Copy to clipboard'><img src='/assets/images/clippy.svg' " \ "alt='Copy to clipboard' style='width: 13px'></button>"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, text, tokens) ⇒ void
constructor
Constructor.
-
#render(context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
Constructor Details
#initialize(tag_name, text, tokens) ⇒ void
Constructor.
37 38 39 40 41 |
# File 'pre.rb', line 37 def initialize(tag_name, text, tokens) super(tag_name, text, tokens) text = '' if text.nil? @make_copy_button = text.strip! == 'copyButton' end |
Class Method Details
.make_copy_button(pre_id) ⇒ Object
22 23 24 |
# File 'pre.rb', line 22 def self.(pre_id) "#{@@prefix}'##{pre_id}'#{@@suffix}" end |
.make_pre(make_copy_button, content) ⇒ Object
26 27 28 29 30 |
# File 'pre.rb', line 26 def self.make_pre(, content) pre_id = 'id${SecureRandom.hex(6)}' = ? PreTagBlock.(pre_id) : '' "<pre data-lt-active='false' class='maxOneScreenHigh copyContainer' id='#{pre_id}'>#{}#{content}</pre>" end |
Instance Method Details
#render(context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
45 46 47 48 |
# File 'pre.rb', line 45 def render(context) content = super PreTagBlock.make_pre(@make_copy_button, content) end |