Skip to content

Instantly share code, notes, and snippets.

@vito
Created September 10, 2010 00:51
Show Gist options
  • Save vito/572857 to your computer and use it in GitHub Desktop.
Save vito/572857 to your computer and use it in GitHub Desktop.
load: "examples/html.atomo"
load: "examples/web.hs"
Association = Object clone
a -> b := Association clone do: { from = a; to = b }
Demo = Website clone do: {
routes = [
"/" -> @index,
"hello/:name" -> @hello:,
-- assigning a route to a block to be called
-- first arg is Demo, but we ignore it here
"some/:block/:args" -> { _ b a | "Got: " .. [b, a] show }
]
}
Demo index =
HTML new (do: {
doctype
html: {
head: {
title: "Hi!"
}
body: {
h1: "Hello, world!"
p: "Hop on over to the REPL and add some methods to the Demo object!"
p: { a: "Another page!" href: "/hello/world" }
}
}
}) (as: String)
Demo hello: name := "Hello, " .. name .. "!"
-- be sure to load this in the REPL and play around with
-- Demo, adding new routes at runtime
{ Demo start-on: 8000 } spawn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment