Fixup {V_[]} in language variables.

This commit is contained in:
Chris 2013-01-28 11:39:39 +00:00
parent 08523c3033
commit e5904772f6

View File

@ -315,10 +315,7 @@ sub replace_langvar {
}
}
# Do any module marker replacements if we can
if($self -> {"modules"}) {
$txtstr =~ s/{B_\[(\w+?)\]}/$self->replace_blockname($1)/ge;
}
$self -> fix_variables(\$textstr);
return $txtstr;
}
@ -506,16 +503,7 @@ sub process_template {
$count += $$textref =~ s/{L_(\w+?)}/$self->replace_langvar($1)/ge;
} while($count);
# Fix 'standard' variables
$$textref =~ s/{V_\[scriptpath\]}/$self->{scriptpath}/g;
$$textref =~ s/{V_\[templatepath\]}/$self->{templatepath}/g;
$$textref =~ s/{V_\[commonpath\]}/$self->{commonpath}/g;
$$textref =~ s/{V_\[sitename\]}/$self->{settings}->{config}->{site_name}/g;
# Do any module marker replacements if we can
if($self -> {"modules"}) {
$$textref =~ s/{B_\[(\w+?)\]}/$self->replace_blockname($1)/ge;
}
$self -> fix_variables($textref);
unless($nocharfix) {
# Convert some common utf-8 characters
@ -535,6 +523,28 @@ sub process_template {
}
## @method $ fix_variables($textref)
# Fix up {V_[name]} and {B_[name]} markers in the specified text. This will replace
# the variable and block markers in the specified text with the expanded equivalents.
#
# @param textref A reference to a string to process.
sub fix_variables {
my $self = shift;
my $textref = shift;
# Fix 'standard' variables
$$textref =~ s/{V_\[scriptpath\]}/$self->{scriptpath}/g;
$$textref =~ s/{V_\[templatepath\]}/$self->{templatepath}/g;
$$textref =~ s/{V_\[commonpath\]}/$self->{commonpath}/g;
$$textref =~ s/{V_\[sitename\]}/$self->{settings}->{config}->{site_name}/g;
# Do any module marker replacements if we can
if($self -> {"modules"}) {
$$textref =~ s/{B_\[(\w+?)\]}/$self->replace_blockname($1)/ge;
}
}
# ============================================================================
# Higher-level templating functions