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 %}"""
{% pre shell %} Content here {% endpre %}
{% pre copyButton shell %} Content here {% endpre %}
{% pre copyButton label %} 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.
56 57 58 59 60 61 62 63 64 |
# File 'pre.rb', line 56 def initialize(tag_name, text, tokens) super(tag_name, text, tokens) text = '' if text.nil? text.strip! @make_copy_button = text.include? 'copyButton' remaining_text = text.sub('copyButton', '').strip #puts "@make_copy_button = '#{@make_copy_button}'; text = '#{text}'; remaining_text = '#{remaining_text}'" @label = remaining_text end |
Class Method Details
.make_copy_button(pre_id) ⇒ Object
34 35 36 |
# File 'pre.rb', line 34 def self.(pre_id) "#{@@prefix}'##{pre_id}'#{@@suffix}" end |
.make_pre(make_copy_button, label, content) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'pre.rb', line 38 def self.make_pre(, label, content) label = if label.to_s.empty? then '' elsif label.to_s.downcase.strip == 'shell' "<div class='codeLabel unselectable' data-lt-active='false'>Shell</div>" else "<div class='codeLabel unselectable' data-lt-active='false'>#{label}</div>" end pre_id = "id#{SecureRandom.hex(6)}" = ? PreTagBlock.(pre_id) : '' "#{label}<pre data-lt-active='false' class='maxOneScreenHigh copyContainer' id='#{pre_id}'>#{}#{content.strip}</pre>" end |
Instance Method Details
#render(context) ⇒ String
Method prescribed by the Jekyll plugin lifecycle.
68 69 70 71 72 |
# File 'pre.rb', line 68 def render(context) content = super #puts "@make_copy_button = '#{@make_copy_button}'; @label = '#{@label}'" PreTagBlock.make_pre(@make_copy_button, @label, content) end |