From 840c5e895cecd40e25853ea85b40f82f258c12d4 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 2 Dec 2024 15:39:58 +0200 Subject: [PATCH] Enable STRICT in the Template-Toolkit code --- .../benchmark/gen-par-mak.pl | 7 ++++++- .../site/wml/lib/FreecellSolver/Site/TTRender.pm | 16 +++++----------- fc-solve/source/scripts/gen-presets.pl | 6 +++++- fc-solve/source/t/generate-card-tests.pl | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cpan/Games-Solitaire-Verify/benchmark/gen-par-mak.pl b/cpan/Games-Solitaire-Verify/benchmark/gen-par-mak.pl index ab56d3f62..01c9c0531 100644 --- a/cpan/Games-Solitaire-Verify/benchmark/gen-par-mak.pl +++ b/cpan/Games-Solitaire-Verify/benchmark/gen-par-mak.pl @@ -2,6 +2,7 @@ use strict; use warnings; +use autodie; use Template (); @@ -19,7 +20,11 @@ step => $STEP, }; -my $template = Template->new( {} ); +my $template = Template->new( + { + STRICT => 1, + } +); my $TEXT = <<'EOF'; all:[% FOREACH i = [min .. max] %] [% res(i) %][% END %] diff --git a/fc-solve/site/wml/lib/FreecellSolver/Site/TTRender.pm b/fc-solve/site/wml/lib/FreecellSolver/Site/TTRender.pm index f2b378096..73d07b8af 100644 --- a/fc-solve/site/wml/lib/FreecellSolver/Site/TTRender.pm +++ b/fc-solve/site/wml/lib/FreecellSolver/Site/TTRender.pm @@ -374,16 +374,13 @@ EOF }; $vars->{enable_jquery_ui} = ( $input_tt2_page_path ne 'js-fc-solve/text/gui-tests.xhtml' ); - + my $src_path = "src/$input_tt2_page_path.tt2"; if ( $self->stdout ) { binmode STDOUT, ':encoding(utf-8)'; my $html = ''; - $template->process( "src/$input_tt2_page_path.tt2", - $vars, \$html, binmode => ':utf8', ) - or die "[[" - . $template->error() - . " ; src/$input_tt2_page_path.tt2 ]]"; + $template->process( $src_path, $vars, \$html, binmode => ':utf8', ) + or die "[[" . $template->error() . " ; $src_path ]]"; $toc->add_toc( \$html ); print $html; @@ -395,11 +392,8 @@ EOF my $d = $rec->{path}; $vars->{production} = $rec->{production}; my $html = ''; - $template->process( "src/$input_tt2_page_path.tt2", - $vars, \$html, binmode => ':utf8', ) - or die "[[" - . $template->error() - . " ; src/$input_tt2_page_path.tt2 ]]"; + $template->process( $src_path, $vars, \$html, binmode => ':utf8', ) + or die "[[" . $template->error() . " ; $src_path ]]"; $toc->add_toc( \$html ); path( @$d, @fn, )->touchpath()->spew_utf8($html); diff --git a/fc-solve/source/scripts/gen-presets.pl b/fc-solve/source/scripts/gen-presets.pl index e4fb0f572..684722179 100644 --- a/fc-solve/source/scripts/gen-presets.pl +++ b/fc-solve/source/scripts/gen-presets.pl @@ -118,7 +118,11 @@ sub compile_preset return; } -my $c_template = Template->new(); +my $c_template = Template->new( + { + STRICT => 1, + }, +); my $C_TEMPLATE_INPUT = <<"EOF"; { diff --git a/fc-solve/source/t/generate-card-tests.pl b/fc-solve/source/t/generate-card-tests.pl index c70107589..2b66b4e7c 100644 --- a/fc-solve/source/t/generate-card-tests.pl +++ b/fc-solve/source/t/generate-card-tests.pl @@ -25,7 +25,7 @@ sub rank_normalize ( path("../include/freecell-solver/fcs_back_compat.h")->slurp_utf8 =~ /^#define FCS_BREAK_BACKWARD_COMPAT_1\r?$/ms ? 1 : 0 ); -my $template = Template->new( { ABSOLUTE => 1, }, ); +my $template = Template->new( { ABSOLUTE => 1, STRICT => 1, }, ); sub indexify {