summaryrefslogtreecommitdiffstats
path: root/globals.pl
diff options
context:
space:
mode:
authormyk%mozilla.org <>2002-05-30 10:44:33 +0200
committermyk%mozilla.org <>2002-05-30 10:44:33 +0200
commita7fc7c232a947d56556c73b00a4a89c1370c9d1d (patch)
tree5778f04b80b953fb61a6591afda4259012711f49 /globals.pl
parentb74ebbd882923412d35bca0c8053a61120d93db5 (diff)
downloadbugzilla-a7fc7c232a947d56556c73b00a4a89c1370c9d1d.tar.gz
bugzilla-a7fc7c232a947d56556c73b00a4a89c1370c9d1d.tar.xz
Fix for bug 148011: Move pseudo-method definitions together.
Patch by Myk Melez <myk@mozilla.org>. 2xr=justdave
Diffstat (limited to 'globals.pl')
-rw-r--r--globals.pl45
1 files changed, 23 insertions, 22 deletions
diff --git a/globals.pl b/globals.pl
index 44e29eafa..bb6a0abc5 100644
--- a/globals.pl
+++ b/globals.pl
@@ -1602,6 +1602,29 @@ $Template::Stash::LIST_OPS->{ containsany } =
return 0;
};
+# Add a "substr" method to the Template Toolkit's "scalar" object
+# that returns a substring of a string.
+$Template::Stash::SCALAR_OPS->{ substr } =
+ sub {
+ my ($scalar, $offset, $length) = @_;
+ return substr($scalar, $offset, $length);
+ };
+
+# Add a "truncate" method to the Template Toolkit's "scalar" object
+# that truncates a string to a certain length.
+$Template::Stash::SCALAR_OPS->{ truncate } =
+ sub {
+ my ($string, $length, $ellipsis) = @_;
+ $ellipsis ||= "";
+
+ return $string if !$length || length($string) <= $length;
+
+ my $strlen = $length - length($ellipsis);
+ my $newstr = substr($string, 0, $strlen) . $ellipsis;
+ return $newstr;
+ };
+
+###############################################################################
sub GetOutputFormats {
# Builds a set of possible output formats for a script by looking for
@@ -1712,28 +1735,6 @@ sub ValidateOutputFormat {
###############################################################################
-# Add a "substr" method to the Template Toolkit's "scalar" object
-# that returns a substring of a string.
-$Template::Stash::SCALAR_OPS->{ substr } =
- sub {
- my ($scalar, $offset, $length) = @_;
- return substr($scalar, $offset, $length);
- };
-
-# Add a "truncate" method to the Template Toolkit's "scalar" object
-# that truncates a string to a certain length.
-$Template::Stash::SCALAR_OPS->{ truncate } =
- sub {
- my ($string, $length, $ellipsis) = @_;
- $ellipsis ||= "";
-
- return $string if !$length || length($string) <= $length;
-
- my $strlen = $length - length($ellipsis);
- my $newstr = substr($string, 0, $strlen) . $ellipsis;
- return $newstr;
- };
-
# Define the global variables and functions that will be passed to the UI
# template. Additional values may be added to this hash before templates
# are processed.