Sha256: 928f4107c588d98107674e01b81ba519010c2d67381a48a4a99394aef4308980

Contents?: true

Size: 515 Bytes

Versions: 2

Compression:

Stored size: 515 Bytes

Contents

module ActiveCopy
  module ViewHelper
    # Render a given relative content path to Markdown.
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_copy-1.0.0 lib/active_copy/view_helper.rb
active_copy-1.0.0.pre lib/active_copy/view_helper.rb