10. Component
the core of Inesita
class Home
include Inesita::Component
def render
div.jubmotron.text_center do
img src: '/static/inesita-rb.png'
h1 do
text "Hello I'm Inesita"
end
component Counter, props: {
header: 'This is a sample counter'
}
end
end
end
12. Router
Using inesita-router gem
class Router
include Inesita::Router
def auth
unless store.logged_in?
go_to('/login')
end
end
def routes
route '/', to: Home
route '/description', to: Description
route '/secret', to: List,
on_enter: method(:auth)
route '/login', to: Login
end
end
13. Lifecycle
methods
#hook and #unhook
class Home
include Inesita::Component
def after_mount(node)
puts "I'm mounted #{node}"
end
def before_remove(node)
puts "I'm removed #{node}"
end
def render
div.jubmotron
hook: hook(:after_mount),
unhook: unhook(:before_remove) do
"Hello"
end
end
end