Class: Gollum::Filter::Render

Inherits:
Gollum::Filter show all
Defined in:
lib/gollum-lib/filter/render.rb

Constant Summary

Constants inherited from Gollum::Filter

PLACEHOLDER_PATTERN

Instance Attribute Summary

Attributes inherited from Gollum::Filter

#close_pattern, #open_pattern

Instance Method Summary collapse

Methods inherited from Gollum::Filter

#initialize

Methods included from Helpers

#path_to_link_text, #trim_leading_slashes

Constructor Details

This class inherits a constructor from Gollum::Filter

Instance Method Details

#extract(data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gollum-lib/filter/render.rb', line 4

def extract(data)
  begin
    working_dir = Pathname.new(@markup.wiki.path).join(@markup.dir)
    working_dir = working_dir.exist? ? working_dir.to_s : '.'
    Dir.chdir(working_dir) do
      if block = @markup.custom_renderer
        data = block.call(data)
      else
        data = GitHub::Markup.render_s(@markup.format, data)
      end
    end
    if data.nil?
      raise "There was an error converting #{@markup.name} to HTML."
    end
  rescue Object => e
    data = html_error("Failed to render page: #{e.message}")
  end

  data
end

#process(data) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/gollum-lib/filter/render.rb', line 25

def process(data)
  if @markup.wiki.allow_editing
    add_editable_header_class(data)
  else
    data
  end
end