Layout Options - wordjelly/Auth GitHub Wiki

Layout and Content_For.

The application.html.erb - layout, in the auth/layouts folder, consists of several partials, all of which can be found in the layouts folder. The navbar partial offers customization in the form of the following content_for() blocks.

  • navbar_left : this block will override the left side of the navbar, so that , both the app_name and spinner will be replaced by whatever you specify in this block.
  • navbar_right : this block replaces the right hand side of the navbar, which normally has the sign_in, sign_out and [account_settings, and profile links] -> the last two through the personalization.html.erb partial.
  • personalization_nav_links : this is called inside the _personalization.html.erb partial. It provides an option to add more links to the left side of the "Account", "Profile Settings" , "Sign Out" options.

content_for, obviously does not work through ajax, or js.erb, because by that time the layout has already rendered and content_for has already been called.

Use

In the layout file, call

<% content_for(:navbar_left) do %>
<some html>
<% end %>

In the navbar partial, content_for has already been added as follows:

<% if content_for?(:navbar_left) %>
<%= content_for(:navbar_left) %>
<% end %>

Engine Layout vs Application Layout

If any url points to a controller specified by the engine, then the engine layout is used. even if the engine application controller has inherited from the app application controller. There are two ways to override this behaviour:

  1. explicity specify layout : 'application' in the app application controller
  2. delete the appilication.html.erb from the engine layouts.

Option one is preferable, since we can override the layout in different controllers of the app by using this technique.

⚠️ **GitHub.com Fallback** ⚠️