Class: Jekyll::Tags::RustPlaygroundHighlight

Inherits:
HighlightBlock
  • Object
show all
Defined in:
lib/rust_playground_highlight.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gist_idObject

Returns the value of attribute gist_id.



5
6
7
# File 'lib/rust_playground_highlight.rb', line 5

def gist_id
  @gist_id
end

#rawObject

Returns the value of attribute raw.



5
6
7
# File 'lib/rust_playground_highlight.rb', line 5

def raw
  @raw
end

Instance Method Details

#add_code_tag(code) ⇒ Object



7
8
9
# File 'lib/rust_playground_highlight.rb', line 7

def add_code_tag(code)
  super.sub(/\n*<\/pre>/,"</pre><a href='#{playground_url}' target='_new' class='playground btn btn-xs btn-primary active' role='button'>Run</a>").strip
end

#options_hashObject

The @options ivar was renamed to @highlight_options in commit: github.com/jekyll/jekyll/commit/a7730914df272d003de6d3b63669e8e8417e0c61



20
21
22
# File 'lib/rust_playground_highlight.rb', line 20

def options_hash
  instance_variable_get(:@highlight_options) || instance_variable_get(:@options)
end

#playground_urlObject



24
25
26
# File 'lib/rust_playground_highlight.rb', line 24

def playground_url
  PlaygroundLink.build(self).url
end

#render(context) ⇒ Object



11
12
13
14
15
16
# File 'lib/rust_playground_highlight.rb', line 11

def render(context)
  #calls render on Liquid::Block, which returns the content of the block
  self.raw = self.method(:render).super_method.super_method.call(context).to_s.strip
  self.gist_id = options_hash[:playground_id]
  super
end