Starting to play with HTML::Template
authortonnesen <tonnesen>
Fri, 10 May 2002 17:08:04 +0000 (17:08 +0000)
committertonnesen <tonnesen>
Fri, 10 May 2002 17:08:04 +0000 (17:08 +0000)
I'm going to work on the search interface instead of the circulation interface
as the search interface is where my librarians want the most changes at the
moment.

html-template/search.pl [new file with mode: 0755]
html-template/searchresults.tmpl [new file with mode: 0644]

diff --git a/html-template/search.pl b/html-template/search.pl
new file mode 100755 (executable)
index 0000000..91e4ed5
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+use HTML::Template;
+
+my $template = HTML::Template->new(filename => 'searchresults.tmpl', die_on_bad_params => 0);
+
+$template->param(PET => 'Allie');
+$template->param(NAME => 'Steve Tonnesen');
+
+
+$template->param(SEARCH_RESULTS => [ { barcode => '123456789', title => 'Me and My Dog', author => 'Jack London', dewey => '452.32' },
+                                    { barcode => '153253216', title => 'Dogs in Canada', author => 'Jack London', dewey => '512.3' },
+                                    { barcode => '163214576', title => 'Howling at the Moon', author => 'Jack London', dewey => '476' }
+                                    ]
+               );
+
+
+print "Content-Type: text/html\n\n", $template->output;
diff --git a/html-template/searchresults.tmpl b/html-template/searchresults.tmpl
new file mode 100644 (file)
index 0000000..1ab220f
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head><title>Test Template</title>
+</head>
+<body>
+Testing <TMPL_VAR NAME=NAME>
+<p>
+Pet's Name: <TMPL_VAR NAME=PET>
+<p>
+<hr>
+<table border=1>
+<tr><th>Barcode</th><th>Title</th><th>Author</th><th>Dewey</th></tr>
+<TMPL_LOOP NAME=SEARCH_RESULTS>
+  <tr>
+  <td> <TMPL_VAR NAME=BARCODE> </td>
+  <td> <TMPL_VAR NAME=TITLE> </td>
+  <td> <TMPL_VAR NAME=AUTHOR> </td>
+  </tr>
+</TMPL_LOOP>
+</table>
+<hr>
+</body>
+</html>