jnicklas / chianna

Component based Web Development Framework

chianna / app.rb
100644 41 lines (29 sloc) 0.576 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'lib/chianna.rb'
 
class Counter < Component
  
  def render
    puts self.value.inspect
    self.value ||= rand(10000)
    
    div.counter {
      h1 "This is the counter component"
      h2 self.value
      p "How's it going?"
      div.test! {
        component Clock
      }
    }
  end
  
end
 
class Clock < Component
  
  def render
    self.value ||= Time.now.to_s
    
    div.clock {
      p self.value
    }
  end
  
end
 
Chianna.connect
 
app = Chianna::Application.new
 
app.map Counter, '/'
app.map Counter, '/counter'
app.map Clock, '/clock'
 
app.run