Class: Jekyll::Maps::GoogleMapApi

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

Constant Summary collapse

HEAD_END_TAG =
%r!</[\s\t]*head>!
BODY_END_TAG =
%r!</[\s\t]*body>!

Class Method Summary collapse

Class Method Details

.prepend_api_code(doc) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/jekyll-maps/google_map_api.rb', line 8

def prepend_api_code(doc)
  @config = doc.site.config
  if doc.output =~ HEAD_END_TAG
    # Insert API code before header's end if this document has one.
    doc.output.gsub!(HEAD_END_TAG, %(#{api_code}#{Regexp.last_match}))
  else
    doc.output.prepend(api_code)
  end
end

.prepend_google_api_code(doc) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/jekyll-maps/google_map_api.rb', line 18

def prepend_google_api_code(doc)
  @config = doc.site.config
  if doc.output =~ BODY_END_TAG
    # Insert API code before body's end if this document has one.
    doc.output.gsub!(BODY_END_TAG, %(#{google_api_code}#{Regexp.last_match}))
  else
    doc.output.prepend(api_code)
  end
end