Module: SimpleDiscussion::ForumThreadsHelper

Defined in:
app/helpers/simple_discussion/forum_threads_helper.rb

Instance Method Summary collapse

Instance Method Details



7
8
9
10
11
12
13
14
# File 'app/helpers/simple_discussion/forum_threads_helper.rb', line 7

def forum_link_class(matches, opts = {})
  case matches
  when Array
    "active" if matches.any? { |m| request.path.starts_with?(m) }
  when String
    "active" if opts.fetch(:exact, false) ? request.path == matches : request.path.starts_with?(matches)
  end
end

Used for flagging links in the navbar as active



3
4
5
# File 'app/helpers/simple_discussion/forum_threads_helper.rb', line 3

def forum_link_to(path, opts = {}, &block)
  link_to path, class: forum_link_class(path, opts), &block
end

#parent_layout(layout) ⇒ Object

A nice hack to manipulate the layout so we can have sub-layouts without any changes in the user’s application.

We use this for rendering the sidebar layout for all the forum pages

mattbrictson.com/easier-nested-layouts-in-rails



23
24
25
26
27
# File 'app/helpers/simple_discussion/forum_threads_helper.rb', line 23

def parent_layout(layout)
  @view_flow.set(:layout, output_buffer)
  output = render(template: "layouts/#{layout}")
  self.output_buffer = ActionView::OutputBuffer.new(output)
end