(translations) You can
either do:
# in your TT-template
[% show_username %]
# in your code with encodeFor('HTML')
show_username => __x("Username: {user}", user => $user->name),
Shorter:
# in your TT-template with encodeFor('HTML')
[% loc("Username: {user}", user => username) %]
# in your code
username => $user->name,
Even shorter:
# in your TT-template with encodeFor('HTML')
[% loc("Username: {user.name}", user => userobj) %]
# in your code
userobj => $user,
Shortest:
# in your TT-template with encodeFor('HTML')
[% loc("Username: {user.name}") %]
# in your code
user => $user,
Shorter that the original, and translations for free!
More examples in Log::Report::Template.
=head3 Output encoding exclusion
In some cases, the data which is inserted is already encoded in the
output syntax. For instance, you already have HTML to be included.
The default exclusion rule for HTML output is C<< qr/html$/i >>, which
means that all inserted named parameters, where the name ends on C
will not get html-entity encoded.
This will work by default:
# with encodeFor('HTML')
printp "Me & Co: {name}, {description_html}",
name => 'RenE', description_html => $descr;
This may result in:
Me Eamp; Co: RenEeacute;, new member
Better not to have HTML in your program: leave it to the template. But
in some cases, you have no choice.
=head2 String::Print compared to other modules on CPAN
There are a quite a number of modules on CPAN which extend the functionality
of C. To name a few:
L,
L,
L,
L,
L,
L,
L, and
L.
They are all slightly different.
When the C module was created, none of the modules
mentioned above handled unicode correctly. Global configuration
of serializers and modifiers is also usually not possible, sometimes
provided per explicit function call. Only C cleanly
separates the roles of serializers, modifiers, and conversions.
C is nicely integrated with Log::Report.
=head1 SEE ALSO
This module is part of String-Print version 1.02,
built on December 09, 2025. Website: F
=head1 LICENSE
For contributors see file ChangeLog.
This software is copyright (c) 2016-2025 by Mark Overmeer.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
String-Print-1.02/Makefile.PL 0000644 0001750 0000144 00000003613 15115534256 016476 0 ustar 00markov users 0000000 0000000 use ExtUtils::MakeMaker;
use 5.016;
# Use command 'oodist' to produce your whole software release.
my $version = '1.02';
my $git = "https://github.com/markov2/perl5-String-Print";
my $publish = "../public_html/string-print";
my $homepage = "http://perl.overmeer.net/CPAN/";
my %oodist = (
oodoc_version => 3.04,
first_year => 2016,
email => "markov\@cpan.org",
include => [
],
use => [
],
parser => {
syntax => 'markov',
skip_links => [
'Locale::TextDomain',
],
pmhead => undef,
},
tests => {
},
release => {
publish => "$publish/source",
},
raw => {
publish => "$publish/raw",
},
generate => [
{ # Add real pod to the releases
format => 'pod3',
podtail => undef,
},
# You may add HTML formatters here.
# You may add exporter configurations here.
],
);
my %requires = (
'Test::More' => 0.86,
'Unicode::GCString' => 0,
'Encode' => 0,
'HTML::Entities' => 0,
'Date::Parse' => 2.30,
);
my %optional = (
'DateTime' => 1.00,
);
WriteMakefile
NAME => 'String::Print',
VERSION => $version,
AUTHOR => 'Mark Overmeer ',
ABSTRACT => 'printf extensions',
LICENSE => 'perl_5',
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => "$git.git",
web => $git,
},
bugtracker => {
web => "$git/issues",
},
homepage => $homepage,
license => [ 'http//dev.perl.org/licenses/' ],
},
prereqs => {
runtime => {
requires => \%requires,
optional => \%optional,
},
develop => {
requires => {
'OODoc' => 3.04,
},
},
test => {
requires => {
'Test::More' => 1.00,
'Test::Pod' => 1.00,
},
},
},
# You may use multiple set-ups, see "oodist --make"
x_oodist => \%oodist,
};
String-Print-1.02/ChangeLog 0000644 0001750 0000144 00000005771 15116015372 016277 0 ustar 00markov users 0000000 0000000
========== version history of String::Print
All modifications where created by Mark Overmeer, unless explicitly
stated differently.
version 1.02: Tue 9 Dec 13:49:31 CET 2025
Changes:
- remove the blank before kB in BYTES.
Fixes:
- remove correct redundant separator from thousands in %d
- do not use %F and %T in date formats, for broken Windows
github issue #2 [Phil Perry]
Improvements:
- flexible format for the DT modifier
- formats for DATE modifier
version 1.01: Thu 4 Dec 16:43:36 CET 2025
Improvements:
- add UNKNOWN modifier
- doc improvements
version 1.00: Wed 3 Dec 13:21:40 CET 2025
Improvements:
- add bugtracker to meta
- add ellipsis EL modifier
- add CHOP modifier
- add defaults configuration
- better document encodeFor()
- add DateTime support for time modifiers
version 0.96: Fri 12 Sep 14:01:16 CEST 2025
Improvements:
- thousands markers in %d
- add date modifier RFC5322
- add modifier '='
- further documentation improvements
version 0.95: Mon 8 Sep 14:06:53 CEST 2025
Changes:
- require 5.16
Fixes:
- printp formats which start with a '%' were not processed
Improvements:
- modifier HTML
- add .gitignore
- convert to OODoc 3.03
version 0.94: Sun 1 Mar 12:37:41 CET 2020
Fixes:
- fix metadata [Mohammad S Anwar]
- test failed when year with blanks [cpantesters]
version 0.93: Tue Jan 23 22:08:31 CET 2018
Improvements:
- convert to GIT
- publish via GitHUB
version 0.92: Thu 6 Jul 12:31:36 CEST 2017
Fixes:
- %F and %T not supported on Windows [cpantesters]
version 0.91: Tue 27 Jun 17:10:58 CEST 2017
Improvements:
- add output encoding (encodeFor)
- add complex keys
- add modifier BYTES
- add time modifiers
- add default modifier '//'
- add new(missing_key) with warning
version 0.90: Wed 14 Jun 14:47:03 CEST 2017
Improvements:
- spell-fix rt.cpan.org#96464 [Gregor Herrmann, Debian]
version 0.15: Fri Mar 14 09:06:18 CET 2014
Fixes:
- t/11modif.t regression test, where float may get ',' under
some locales [cpantesters]
version 0.14: Mon Mar 10 16:11:30 CET 2014
Improvements:
- changed documentation style
version 0.13: Sun Jan 5 16:51:09 CET 2014
Improvements:
- docs: fune-tuning
- serializer for SCALAR
- accept blanks around names of interpolated variable names
- accept digits in variable names, not as first character.
version 0.12: Mon Apr 29 09:16:23 CEST 2013
Changes:
- %c --> %S [Amsterdam Perl Mongers]
Improvements:
- docs: correct syntax for links to alternative modules.
- docs: PND -> GBP [H.Merijn Brand]
version 0.11: Tue Apr 16 12:27:54 CEST 2013
Fixes:
- require perl 5.10 for '//' operator [cpantesters]
- fix tests to use gmtime, not localtime [cpantesters]
- some documentation layout improvements [search.cpan.org]
- in examples: strftime "%TT%FZ" --> "%FT%TZ", of course
- in tests: Windows doesn't support %T nor %F, expand format
- any format with strings must be transformed into utf8
version 0.10: Mon Apr 15 12:06:32 CEST 2013
- implementation, documentation and regression tests.
String-Print-1.02/META.yml 0000644 0001750 0000144 00000002274 15116015375 015774 0 ustar 00markov users 0000000 0000000 ---
abstract: 'printf extensions'
author:
- 'Mark Overmeer '
build_requires:
ExtUtils::MakeMaker: '0'
Test::More: '1'
Test::Pod: '1'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.76, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: String-Print
no_index:
directory:
- t
- inc
requires:
Date::Parse: '2.3'
Encode: '0'
HTML::Entities: '0'
Test::More: '0.86'
Unicode::GCString: '0'
resources:
bugtracker: https://github.com/markov2/perl5-String-Print/issues
homepage: http://perl.overmeer.net/CPAN/
repository: https://github.com/markov2/perl5-String-Print.git
version: '1.02'
x_oodist:
email: markov@cpan.org
first_year: 2016
generate:
-
format: pod3
podtail: ~
include: []
oodoc_version: 3.04
parser:
pmhead: ~
skip_links:
- Locale::TextDomain
syntax: markov
raw:
publish: ../public_html/string-print/raw
release:
publish: ../public_html/string-print/source
tests: {}
use: []
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
String-Print-1.02/META.json 0000644 0001750 0000144 00000004421 15116015375 016140 0 ustar 00markov users 0000000 0000000 {
"abstract" : "printf extensions",
"author" : [
"Mark Overmeer "
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.76, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "String-Print",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"develop" : {
"requires" : {
"OODoc" : "3.04"
}
},
"runtime" : {
"requires" : {
"Date::Parse" : "2.3",
"Encode" : "0",
"HTML::Entities" : "0",
"Test::More" : "0.86",
"Unicode::GCString" : "0"
},
"x_optional" : {
"DateTime" : 1
}
},
"test" : {
"requires" : {
"Test::More" : "1",
"Test::Pod" : "1"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/markov2/perl5-String-Print/issues"
},
"homepage" : "http://perl.overmeer.net/CPAN/",
"repository" : {
"type" : "git",
"url" : "https://github.com/markov2/perl5-String-Print.git",
"web" : "https://github.com/markov2/perl5-String-Print"
}
},
"version" : "1.02",
"x_oodist" : {
"email" : "markov@cpan.org",
"first_year" : 2016,
"generate" : [
{
"format" : "pod3",
"podtail" : null
}
],
"include" : [],
"oodoc_version" : 3.04,
"parser" : {
"pmhead" : null,
"skip_links" : [
"Locale::TextDomain"
],
"syntax" : "markov"
},
"raw" : {
"publish" : "../public_html/string-print/raw"
},
"release" : {
"publish" : "../public_html/string-print/source"
},
"tests" : {},
"use" : []
},
"x_serialization_backend" : "JSON::PP version 4.16"
}