Class: Brut::FrontEnd::Layout
- Defined in:
- lib/brut/front_end/layout.rb
Overview
A layout is common HTML that surrounds different pages. For example, it would hold your
DOCTYPE, <head>
, and possibly any common <body>
elements that every page needs.
A layout is a Phlex component but it must contain a call to yield
somewhere in the
implementation of view_template
.
This base class contains helper methods needed for implementing a layout.
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Access the page being laid out.
Instance Method Summary collapse
-
#asset_path(path) ⇒ String
Get the actual path of an asset managed by Brut.
-
#initialize(page:) ⇒ Layout
constructor
Create the layout for a given page.
Methods inherited from Component
#around_template, component_name, #component_name
Methods included from Component::Helpers
#entity, #global_component, #inline_svg
Methods included from I18n::ForHTML
Methods included from I18n::BaseMethods
#l, #t, #t_direct, #this_field_value
Methods included from Brut::Framework::Errors
Constructor Details
#initialize(page:) ⇒ Layout
Create the layout for a given page.
16 17 18 |
# File 'lib/brut/front_end/layout.rb', line 16 def initialize(page:) @page = page end |
Instance Attribute Details
#page ⇒ Object (readonly)
Access the page being laid out
11 12 13 |
# File 'lib/brut/front_end/layout.rb', line 11 def page @page end |
Instance Method Details
#asset_path(path) ⇒ String
Get the actual path of an asset managed by Brut. This handles locating the asset's URL as well as ensuring the hash is properly inserted into the filename.
29 |
# File 'lib/brut/front_end/layout.rb', line 29 def asset_path(path) = Brut.container.asset_path_resolver.resolve(path) |