Rails Controller Integration

Just like a Rails layout would yield a Rails view, a Matestack layout yields a Matestack page. The layout uses Matestack's HTML rendering mechanism in a response method and may additionally call other components in order to define a specific UI.

app/matestack/some_app/some_layout.rb
class SomeApp::SomeLayout < Matestack::Ui::Layout

  def response
    h1 "Some App"
    main do
      yield
    end
  end

end

In this basic example the layout is using the methods h1 and main in order to create the markup as well as a yield in order to yield a page on a specific position.

A Matestack layout itself will be yielded into the Rails layout, unless the Rails layout is disabled in the controller via:layout false

Usually a layout implies a specific context of your application. Multiple pages are then scoped within that context, which could lead to a file structure like:

app/matestack/
|
└───some_app/
      some_layout.rb
   └───pages/
         page1.rb
         page2.rb
         page3.rb

and then used in a controller like this:

Last updated

Was this helpful?