Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
a7fc7c23
Commit
a7fc7c23
authored
May 30, 2002
by
myk%mozilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug 148011: Move pseudo-method definitions together.
Patch by Myk Melez <myk@mozilla.org>. 2xr=justdave
parent
b74ebbd8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
globals.pl
globals.pl
+23
-22
No files found.
globals.pl
View file @
a7fc7c23
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment