Class: Jekyll::ScalaFiddle::ScalaFiddleIntegration

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-scalafiddle.rb

Constant Summary collapse

BODY_END_TAG =
%r!</body>!

Class Method Summary collapse

Class Method Details

.append_scalafiddle_code(doc) ⇒ Object



121
122
123
124
125
126
127
128
129
130
# File 'lib/jekyll-scalafiddle.rb', line 121

def append_scalafiddle_code(doc)
  @config = doc.site.config
  if doc.output =~ BODY_END_TAG
    # Insert code before body's end if this document has one.
    location = doc.output.index(BODY_END_TAG)
    doc.output = doc.output.slice(0, location) + api_code(doc) + doc.output.slice(location, doc.output.length - location)
  else
    doc.output.prepend(api_code(doc))
  end
end