Sha256: 59c3e06d4e29e6d342961a46283665009ff0a43943fd3c6ab6531913198c4678
Contents?: true
Size: 949 Bytes
Versions: 1
Compression:
Stored size: 949 Bytes
Contents
module SimpleDiscussion::ForumThreadsHelper # Used for flagging links in the navbar as active def forum_link_to(path, opts = {}, &block) link_to path, class: forum_link_class(path, opts), &block end 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 # 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 # # https://mattbrictson.com/easier-nested-layouts-in-rails # def parent_layout(layout) @view_flow.set(:layout, output_buffer) output = render(template: "layouts/#{layout}") self.output_buffer = ActionView::OutputBuffer.new(output) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_discussion-1.3.0 | app/helpers/simple_discussion/forum_threads_helper.rb |