From 22b2ef875a44820e0758f32f42606522f46a8289 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 27 Mar 2017 10:25:35 +0100 Subject: [PATCH] Improve reporting of odd tempalte behaviour --- Webperl/Template.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Webperl/Template.pm b/Webperl/Template.pm index 9983f6e..e1e1f34 100644 --- a/Webperl/Template.pm +++ b/Webperl/Template.pm @@ -123,7 +123,7 @@ package Webperl::Template; use experimental qw(smartmatch); use POSIX qw(strftime); use Webperl::Utils qw(path_join superchomp); -use Carp qw(longmess); +use Carp qw(longmess carp); use HTML::WikiConverter; use HTML::Entities; use v5.12; @@ -516,10 +516,16 @@ sub process_template { my $varmap = shift; my $nocharfix = shift; + carp("No text passed to process_template") + unless($text); + # If text is a reference already, we can just use it. Otherwise we need # to make a reference to the text to simplify the code in the loop below. my $textref = ref($text) ? $text : \$text; + carp("No text passed to process_template") + unless($$textref); + # replace all the keys in the text with the appropriate value. my ($key, $value, $count); my $limit = 0; @@ -551,6 +557,9 @@ sub process_template { # Convert horrible smart quote crap from windows foreach my $char (keys(%$entities)) { + carp("Error replacing entitiy: $char, no replacement.") + if(!$char || !$entities -> {$char}); + $$textref =~ s/$char/$entities->{$char}/g; } }