Module: Garage::Docs::ResourcesHelper

Defined in:
app/helpers/garage/docs/resources_helper.rb

Overview

coding: utf-8

Instance Method Summary collapse

Instance Method Details

#action_classesObject



21
22
23
# File 'app/helpers/garage/docs/resources_helper.rb', line 21

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

#doc_name(resource) ⇒ Object



17
18
19
# File 'app/helpers/garage/docs/resources_helper.rb', line 17

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

#markdown(text) ⇒ Object



12
13
14
15
# File 'app/helpers/garage/docs/resources_helper.rb', line 12

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

#markdown_file(file) ⇒ Object



6
7
8
9
10
# File 'app/helpers/garage/docs/resources_helper.rb', line 6

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