File: nest.rb

package info (click to toggle)
html-template 0.16-2.1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 128 kB
  • ctags: 111
  • sloc: ruby: 869; makefile: 41
file content (36 lines) | stat: -rwxr-xr-x 547 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/ruby

require "html/template"

tmpl = HTML::Template.new("filename" => "nest.html")

PARENT = [
  { "p_var" => "PARENT 1",
    "child" => [
      {
	"hoge" => "CHILD 1-1",
	"c_var" => "1-1"
      },
      {
	"hoge" => "CHILD 1-2",
	"c_var" => "1-2"
      },
      ]
  },
  { "p_var" => "PARENT 2",
    "child" => [
      {
	"hoge" => "CHILD 2-1",
	"c_var" => "2-1"
      },
      {
	"hoge" => "CHILD 2-2",
	"c_var" => "2-2"
      },
      ]
  },
  ]

tmpl.param({"parent" => PARENT})
print "Content-Type: text/html\n\n"
print tmpl.to_s