class SomePage < Matestack::Ui::Page
def response
div id: "my-page" do
my_partial "foo from page"
end
end
private # optionally mark your partials as private
def my_partial text
div class: "nested"
plain text
end
end
end
module MySharedPartials
def my_partial text
div class: "nested"
plain text
end
end
end
class SomePage < Matestack::Ui::Page
include MySharedPartials
def response
div id: "my-page" do
my_partial "foo from component"
end
end
end
class SomePage < Matestack::Ui::Page
def response
div id: "my-page" do
if is_admin?
latest_users.each do |user|
div do
plain user.name # ...
end
end
else
plain "not authorized"
end
end
end
private # optionally mark your helper methods as private
def is_admin?
true # some crazy Ruby logic!
end
def latest_users
User.last(10) # calling ActiveRecord models for example
end
end
class SomePage < Matestack::Ui::Page
def prepare
@some_data = "some data"
end
def response
div id: "my-page" do
plain @some_data
end
end
end
class SomePage < Matestack::Ui::Page
def response
div id: "my-page" do
plain params[:foo]
end
end
end
class SoomeController < ActionController::Base
include Matestack::Ui::Core::Helper
def some_page
render SomePage, foo: 'bar', bar: 'baz'
end
end
class SomePage < Matestack::Ui::Page
required :foo
optional :bar
def response
div id: "my-page" do
plain context.foo # "bar"
plain context.bar # "baz"
end
end
end