Text::Template

Expand template text with embedded Perl

Latest version: 1.61 registry icon
Maintenance score
0
Safety score
0
Popularity score
7
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
1.61 0 0 0 1 0
1.60 0 0 0 1 0
1.59 0 0 0 1 0
1.58 0 0 0 1 0
1.57 0 0 0 1 0
1.56 0 0 0 1 0
1.55 0 0 0 1 0
1.54 0 0 0 1 0
1.53 0 0 0 1 0
1.52 0 0 0 1 0
1.51 0 0 0 1 0
1.50 0 0 0 1 0
1.49 0 0 0 1 0
1.48 0 0 0 1 0
1.47 0 0 0 1 0

Stability
Latest release:

1.61 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Artistic-1.0   -   Artistic License 1.0

Not a wildcard

Not proprietary

OSI Compliant


GPL-1.0-or-later   -   GNU General Public License v1.0 or later

Not a wildcard

Not proprietary

OSI Compliant



Text::Template

This is a library for generating form letters, building HTML pages, or filling in templates generally. A template' is a piece of text that has little Perl programs embedded in it here and there. When you fill in' a template, you evaluate the little programs and replace them with their values.

Here's an example of a template:

Dear {$title} {$lastname},

It has come to our attention that you are delinquent in your
{$monthname[$last_paid_month]} payment.  Please remit
${sprintf("%.2f", $amount)} immediately, or your patellae may
be needlessly endangered.

		Love,

		Mark "{nickname(rand 20)}" Dominus

The result of filling in this template is a string, which might look something like this:

Dear Mr. Gates,

It has come to our attention that you are delinquent in your
February payment.  Please remit
$392.12 immediately, or your patellae may
be needlessly endangered.


		Love,

		Mark "Vizopteryx" Dominus

You can store a template in a file outside your program. People can modify the template without modifying the program. You can separate the formatting details from the main code, and put the formatting parts of the program into the template. That prevents code bloat and encourages functional separation.

You can fill in the template in a `Safe' compartment. This means that if you don't trust the person who wrote the code in the template, you won't have to worry that they are tampering with your program when you execute it.


Text::Template was originally released some time in late 1995 or early 1996. After three years of study and investigation, I rewrote it from scratch in January 1999. The new version, 1.0, was much faster, delivered better functionality and was almost 100% backward-compatible with the previous beta versions.

I have added a number of useful features and conveniences since the 1.0 release, while still retaining backward compatibility. With one merely cosmetic change, the current version of Text::Template passes the test suite that the old beta versions passed.