Module: Trestle::ContainerHelper
- Defined in:
- app/helpers/trestle/container_helper.rb
Defined Under Namespace
Classes: Context
Instance Method Summary collapse
-
#container(**attributes, &block) ⇒ Object
Renders a content container with an optional sidebar, which can be useful when creating an admin or dashboard with a custom view.
Instance Method Details
#container(**attributes, &block) ⇒ Object
Renders a content container with an optional sidebar, which can be useful when creating an admin or dashboard with a custom view.
This helper accepts a block (within which the main content is provided), which yields a ‘Context` capture object. The Context object has one important method – `sidebar(**attributes, &block)` which captures the sidebar content to be rendered after the main content.
attributes - Additional HTML attributes to add to the <div> tag
Examples
<%= container do |c| %>
This content will be wrapped in a .main-content-container > .main-content div.
<% end %>
<%= container do |c| %>
<% c.sidebar class: "order-first" %>
Sidebar content...
<% end %>
Main content...
<% end %>
Returns a HTML-safe String.
27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/trestle/container_helper.rb', line 27 def container(**attributes, &block) context = Context.new(self) content = capture(context, &block) if block_given? tag.div(**attributes.merge(class: ["main-content-container", attributes[:class]])) do concat tag.div(content, class: "main-content") concat context. if context. end end |