| 1 | #!/usr/bin/env perl | ||
| 2 | 1 | ▶ | use v5.20; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use File::Temp 'tempfile'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Text::Stencil; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # create a template file with section markers | ||
| 8 | 1 | my ($fh, $fname) = tempfile(SUFFIX => '.tpl', UNLINK => 1); | |
| 9 | 1 | print $fh <<'TPL'; | |
| 10 | __HEADER__ | ||
| 11 | <ul> | ||
| 12 | __ROW__ | ||
| 13 | <li>{name:html} ({score:int})</li> | ||
| 14 | __FOOTER__ | ||
| 15 | </ul> | ||
| 16 | TPL | ||
| 17 | 1 | close $fh; | |
| 18 | |||
| 19 | 1 | my $s = Text::Stencil->from_file($fname); | |
| 20 | |||
| 21 | 1 | say $s->render([ | |
| 22 | { name => 'Alice & Bob', score => 95 }, | ||
| 23 | { name => '<Eve>', score => 87 }, | ||
| 24 | ]); | ||