Skip to content

Commit

Permalink
new readme
Browse files Browse the repository at this point in the history
  • Loading branch information
julesjacobs committed Nov 11, 2010
1 parent f2991cc commit c80b5ff
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion README.markdown
@@ -1,4 +1,62 @@
Raamwerk
========

A toy Ruby framework based on continuations.
A toy proof of concept Ruby framework based on continuations.

Usage:
gem install sinatra
ruby arcchallenge.rb

The solution to the arc challenge:

```ruby
page '/' do
form do
msg = input()
submit do
link("Click me"){ puts "You said #{msg}" }
end
end
end
```

As you can see you can use normal lexically scoped variables for inputs. This is an improvement over Arc which does not provide an abstraction over form input, you have to use string keys into request parameters to get form input.

A counter with links to increase and decrease the count:

```ruby
def counter(i)
puts "the counter is #{i}"
link("increase") { counter(i+1) }
link("decrease") { counter(i-1) }
end

page '/' do
counter(0)
end
```

A todolist application looks like this:

```ruby
$todo = []

def todo
tag(:ul) do
$todo.each do |x|
tag(:li){puts x; link("delete"){ $todo.delete(x); todo }}
end
end

form do
t = input()
submit { $todo << t; todo }
end
end

page '/' do
todo
end
```

This displays a list of todo items with delete links, and a form to add an item.

0 comments on commit c80b5ff

Please sign in to comment.