header_actions
The header_actions
hook is used to specify any additional action links in the page chrome header. The content provided will be rendered as an <li>
inside the <ul>
element that contains the Login/Logout and Proxying links.
This is not a Standard (3-Option) Hook, and should therefore not be called using content_for
.
Usage
View level: use the
set_headers_actions
, as in the first example below:// app/views/resources/show.html.erb <% set_header_actions( link_to('Email PO', gather_feedback_path, class: 'btn btn-link') ) %>
(NB: the
'btn btn-link'
classes, which will help it look like its fellow header actions)Helper/controller:
# app/controllers/application_controller.rb class ApplicationController < PmacsAppResources::BaseController def header_actions [helpers.link_to('File Report', 'https://hamsterdance.gov', class: 'btn btn-link')] end helper_method :header_actions end
Dropdowns
You can also render dropdown links by passing an array item that is a hash with some required keywords.
[ { text: 'Dropdown', preface: helpers.tag.div('This is an optional preamble', class: 'text-grey-darker m-4'), children: [ { text: 'This one is a link', props: { href: '#' } }, 'This one is plain text' ] } ]
Arbitrary content
You can pass in arbitrary content to be rendered within a li.nav-item
element by supplying a hash entry with the content:
keyword:
[ { content: 'Just a string' }, { content: '<div class="text-red-700>Custom HTML, too</div>'.html_safe }, { content: render_to_string(partial: 'shared/global_search') }, { content: helpers.tag.marquee('Remember <marquee> elements?!') } ]
Remember that your content must be marked as HTML-safe or else it will be sanitized. You can do so with .html_safe
, or by using render_to_string(partial: 'my_cool_partial')
or helpers.tag.<tag here>
, both of which mark their output as HTML-safe.