File: integer.cgi

package info (click to toggle)
libwebapp-ruby 0.4-2.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 240 kB
  • sloc: ruby: 2,245; makefile: 79
file content (22 lines) | stat: -rwxr-xr-x 574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env ruby
require 'webapp'

M = HTree.compile_template <<'End'
<html _template=int(n)>
  <head>
    <title _text>n</title>
  </head>
  <body>
    <h1 _text>n</h1>
    <ul>
    <li><a name=pred _attr_href='WebApp.reluri(:path_info=>"/#{n-1}", :fragment=>"pred")'>pred (<span _text="n-1"/>)</a>
    <li><a name=succ _attr_href='WebApp.reluri(:path_info=>"/#{n+1}", :fragment=>"succ")'>succ (<span _text="n+1"/>)</a>
    </ul>
  </body>
</html>
End

WebApp {|webapp|
  n = webapp.path_info[/-?\d+/].to_i
  HTree.expand_template(webapp) {'<html _call="M.int(n)"/>'}
}