File: templating-xslate.cgi

package info (click to toggle)
libcgi-tiny-perl 1.003-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: perl: 1,307; makefile: 2
file content (24 lines) | stat: -rwxr-xr-x 482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use CGI::Tiny;
use Text::Xslate;
use Data::Section::Simple 'get_data_section';

cgi {
  my $cgi = $_;

  # from templates/
  my $tx = Text::Xslate->new(path => ['templates']);

  # or from __DATA__
  my $tx = Text::Xslate->new(path => [get_data_section]);

  my $foo = $cgi->query_param('foo');
  $cgi->render(html => $tx->render('index.tx', {foo => $foo}));
};

__DATA__
@@ index.tx
<html><body><h1><: $foo :></h1></body></html>