Sha256: d6c4e919df7ca2d59d15728c92ebda00d133e2b520b306eb6c7faf1eb0166450

Contents?: true

Size: 689 Bytes

Versions: 22

Compression:

Stored size: 689 Bytes

Contents

require 'redcarpet'
require 'erb'

# coding: utf-8
module Garage::Docs::ResourcesHelper
  def markdown_file(file)
    search_paths = ["#{file}.#{@locale}.md", "#{file}.md"].map {|base| Rails.root + base }
    md_file = search_paths.find {|path| File.exist?(path) }
    markdown(ERB.new(IO.read(md_file)).result)
  end

  def markdown(text)
    markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, with_toc_data: true, fenced_code_blocks: true)
    markdown.render(text).html_safe
  end

  def doc_name(resource)
    resource.respond_to?(:doc_name) ? resource.doc_name : resource.name
  end

  def action_classes
    %W[#{controller_name}_controller #{action_name}_action]
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
the_garage-2.8.2 app/helpers/garage/docs/resources_helper.rb
the_garage-2.8.1 app/helpers/garage/docs/resources_helper.rb
the_garage-2.8.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.7.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.6.1 app/helpers/garage/docs/resources_helper.rb
the_garage-2.6.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.5.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.4.4 app/helpers/garage/docs/resources_helper.rb
the_garage-2.4.3 app/helpers/garage/docs/resources_helper.rb
the_garage-2.4.2 app/helpers/garage/docs/resources_helper.rb
the_garage-2.4.1 app/helpers/garage/docs/resources_helper.rb
the_garage-2.4.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.3.3 app/helpers/garage/docs/resources_helper.rb
the_garage-2.3.2 app/helpers/garage/docs/resources_helper.rb
the_garage-2.3.1 app/helpers/garage/docs/resources_helper.rb
the_garage-2.3.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.2.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.1.0 app/helpers/garage/docs/resources_helper.rb
the_garage-2.0.3 app/helpers/garage/docs/resources_helper.rb
the_garage-2.0.2 app/helpers/garage/docs/resources_helper.rb