Module: ActiveCopy::ViewHelper

Defined in:
lib/active_copy/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_copy(from_source_path) ⇒ Object

Render a given relative content path to Markdown.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/active_copy/view_helper.rb', line 4

def render_copy from_source_path
  source_path = "#{ActiveCopy.content_path}/#{from_source_path}.md"

  if File.exists? source_path
    raw_source = IO.read source_path
    source = raw_source.split("---\n")[2]
    template = ActiveCopy::Markdown.new
    template.render(source).html_safe
  else
    raise ArgumentError.new "#{source_path} does not exist."
  end
end