summaryrefslogtreecommitdiffstats
path: root/examples/sample.ru
blob: b318f86e5ce4ae6e2475b9d792572ab19d0b6ee6 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env ruby
#
$LOAD_PATH << File.join(File.dirname( File.absolute_path(__FILE__)), '..', 'lib')
#
require 'zorglub'
#
Zorglub::Config.register_engine 'my-engine', 'my-ext'
Zorglub::Config.register_engine 'temp-engine', 'tmp'
Zorglub::Config.root = File.dirname( File.absolute_path(__FILE__) )
#
class Node1 < Zorglub::Node
    #
    def index a1, *a2
        "<title>Node1:index</title><p>a1 : #{a1.inspect}</p><p>a2 : #{a2.inspect}</p>#{html}"
    end
    #
    def alt *args
        "<title>Node1:alt</title>#{html}"
    end
    #
end
#
APP = Zorglub::App.new do
    map '/url1', Node1
end
#
class Node2 < Zorglub::Node
    #
    map APP, '/url2'
    engine 'my-engine'
    layout 'my-layout'
    #
    def index *args
        "<title>Node2</title>#{html}"
    end
    #
    def alt *args
        engine 'temp-engine'
        layout 'temp-layout-name'
        view 'path-to-temp-view'
        "<title>Node2:alt</title>#{html}"
    end
    #
end
#
puts APP.to_hash.inspect
#
map '/' do
    use Rack::ShowExceptions
    run APP
end
#