Skip to content

Instantly share code, notes, and snippets.

@patrixr
Last active February 27, 2021 06:38
Show Gist options
  • Save patrixr/a77caf8affbd7044f92ad75167034927 to your computer and use it in GitHub Desktop.
Save patrixr/a77caf8affbd7044f92ad75167034927 to your computer and use it in GitHub Desktop.
page :home do
header do
add_link 'Home', to: :home
add_link 'Posts', to: :posts
end
section :description, layout: :horizontal do
section :image do
add_image '/some/image'
end
section :text do
add_paragraph %{ Lorem ipsum something something }
end
end
section :contact do
form :contact_form do
text_input :fullname
email_input :email
textarea_input :message
submit do |data, ctx|
# the code of this block will be executed on the server
something(data[:email])
something(data[:message])
ctx.redirect :thank_you_page
end
end
end
end
page :post, params: [:id] do |params|
header do
add_link 'Home', to: :home
add_link 'Posts', to: :posts
end
section :content do
add_paragraph do
Database.getPost(params[:id]).text # dynamic content
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment