In the meanwhile I have found the desired answers,
and finished the regex template code.
Now I am asking if it would be possible to get this
code into the main trunk of the dev.
If this is not possible (perhaps because it is not
generic enough, or other reasons), can you tell me
please if there is a recommended way to "override"
my Generic.pm module from the
Config.pm file?
It behaves the same for operators 'ne' and 'eq', but
adds function for '=~' and '!~' binding operators as
well.
Since these operators have not yet been used in
any DTL files (which I think might be the reason
that they did not work out of the box), there should
not be any compatibility issues.
I am attaching the new dynamic template code
(Located in Generic.pm) below:
# --
# do template if dynamic
# --
$Line =~ s{
}
{
my $Type = $1 || '';
my $TypeKey = $2 || '';
my $Con = $3 || '';
my $ConVal = $4 || '';
my $IsType = $5 || '';
my $IsKey = $6 || '';
my $IsValue = $7 || '';
# --
# do requested actions
# --
my $Tmp;
if ($Type eq 'Text') {
$Tmp = $Self->{LanguageObject}->Get($TypeKey, $Param{TemplateFile}) || '';
}
elsif ($Type eq 'Env' || $Type eq 'Data') {
$Tmp = $GlobalRef->{$Type.'Ref'}->{$TypeKey} || '';
}
else {
$Tmp = $Self->{ConfigObject}->Get($TypeKey) || '';
}
# --
# handle ne and eq case
# --
if ($Con eq 'eq' || $Con eq 'ne') {
if (eval '($Tmp '.$Con.' $ConVal)') {
$GlobalRef->{$IsType.'Ref'}->{$IsKey} = $IsValue;
}
}
# --
# handle =~ and !~ case
else {
my @TmpAr;
if (eval '@TmpAr = ($Tmp '.$Con." $ConVal)") {
my $i;
for ($i=0; $i<@TmpAr; $i++) {
$Data{"Match".($i+1)} = $TmpAr[$i];
}
$GlobalRef->{$IsType.'Ref'}->{$IsKey} = $IsValue;
}
}
"";
}egx;
And yes, an example of how I intend to use it:
e.g from within "TicketView.dtl":
</iframe>"; }>
$Data{"Body"}
This will redirect to render from an iframe when the tag is present, and leave the content untouched otherwise.
Best regards,
Roland