« blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Util/DateTime.pm
↑ Summary
blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Session/Store/DBI.pm »
| 1 | package Dwarf::Util::Xslate; | ||
| 2 | use Dwarf::Pragma; | ||
| 3 | use parent 'Exporter'; | ||
| 4 | use HTML::FillInForm::Lite qw//; | ||
| 5 | use Text::Xslate qw/html_builder html_escape/; | ||
| 6 | |||
| 7 | our @EXPORT_OK = qw/reproduce_line_feed format_yen/; | ||
| 8 | |||
| 9 | sub reproduce_line_feed { | ||
| 10 | return html_builder { | ||
| 11 | my $text = shift // ''; | ||
| 12 | my $escaped = html_escape($text); | ||
| 13 | $escaped =~ s|\n|<br />|g; | ||
| 14 | return $escaped; | ||
| 15 | }; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub format_yen { | ||
| 19 | my ($options) = @_; | ||
| 20 | return html_builder { | ||
| 21 | my $price = shift // ''; | ||
| 22 | my $escaped = html_escape($price); | ||
| 23 | return '' unless defined $price; | ||
| 24 | 1 while $price =~ s/(.*\d)(\d\d\d)/$1,$2/; | ||
| 25 | return $price unless $options->{with_yen}; | ||
| 26 | return '¥ ' . $price; | ||
| 27 | }; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub fillinform { | ||
| 31 | return html_builder(\&HTML::FillInForm::Lite::fillinform); | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; |