Module: Docs::ApplicationHelper

Includes:
Bootstrap::ActiveLinkTo, FontAwesome::Rails::IconHelper
Defined in:
app/helpers/docs/application_helper.rb

Instance Method Summary collapse

Methods included from Bootstrap::ActiveLinkTo

#active_link_to, #active_link_to_class, #is_active_link?

Instance Method Details

#li_active_to(*args, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/docs/application_helper.rb', line 9

def li_active_to(*args, &block)
  options = args.extract_options!
  if block_given?
    buffer = capture(&block)
    if options.has_key?(:dropdown)
      options[:dropdown_html] = buffer
    else
      args.unshift(buffer)
    end
  end
  options[:wrap_tag] = :li
  active_link_to *args, options
end


23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/docs/application_helper.rb', line 23

def li_link_to(*args, &block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  url     = args.pop
  title   = args.pop unless block_given?
  
  link_options = options.delete(:link).presence || {}
  li_options   = { class: (%w(active) if current_page?(url)) }.smart_merge!(options.delete(:li).presence || {})
  
  link = block_given? ? link_to(url, link_options, &block) : link_to(title, url, link_options)
  
   :li, raw(link), li_options
end

#markdown(text) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/docs/application_helper.rb', line 36

def markdown(text)
  renderer = Bootstrap::MarkdownRenderer.new(hard_wrap: true, filter_html: true)
  options = {
    autolink: true,
    fenced_code_blocks: true,
    superscript: true, 
    tables: true
  }
  Redcarpet::Markdown.new(renderer, options).render(text).html_safe
end