Sha256: 86c9958e283496864c61113fbfda95eefa1fd1adb16a92c5297b542830ec1979

Contents?: true

Size: 948 Bytes

Versions: 5

Compression:

Stored size: 948 Bytes

Contents

module HelpCenter::SupportThreadsHelper
  # Used for flagging links in the navbar as active
  def support_link_to(path, opts={}, &block)
    link_to path, class: support_link_class(path, opts), &block
  end

  def support_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 support 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

5 entries across 5 versions & 1 rubygems

Version Path
help_center-0.1.0 app/helpers/help_center/support_threads_helper.rb
help_center-0.0.9 app/helpers/help_center/support_threads_helper.rb
help_center-0.0.8 app/helpers/help_center/support_threads_helper.rb
help_center-0.0.7 app/helpers/help_center/support_threads_helper.rb
help_center-0.0.6 app/helpers/help_center/support_threads_helper.rb