in reply to Re^4: Here documents in blocks
in thread Here documents in blocks
some require pluralisation whilst other don't.
Have you seen Lingua::EN::Inflexion? It allows you to construct a generic pattern (a template of sorts) to handle various cases like this.
If there is a way to simplify it which can be quickly implemented then I would certainly change my approach.
It can be quickly implemented, if not quickly learnt. Because these are modules with which I am familiar I would use Template for the templating system with the Template::Plugin::Lingua::EN::Inflexion plugin which would allow for a simple loop to produce the table contents and proper pluralisation of the prose. TIMTOWTDI, of course.
#!/usr/bin/env perl use strict; use warnings; use Template; # Set up your data my $data = { table => [ { head => 'Bookings this month', val => 132, }, { head => 'Previous 30 days', val => 99, }, { head => 'Forthcoming 30 days', val => 150, }, { head => 'Forthcoming 60 days', val => 189, }, ], event_count => 1, call_list => 5 }; # Set up your template (easiest/commonest in an external datastore (fi +le # or DB) my $template = <<EOT; <div style="float:right"> <p class="sectionHead"><b>FHL Properties:</b></p> <table> [% FOR k IN table %] <tr> <th class="itemHead">[% k.head %]:</th> <td>[% k.val %] </td> </tr> [% END %] </table> </div> <hr style="clear:both"> [% USE infl = Lingua.EN.Inflexion; FILTER inflect; -%] <p class="sectionHead"><b>Progress in Property Event:</b></p> <p class="itemHeadLarge"><#:[% event_count %]> <N:person> <V:has> regi +stered their interest.</p> <hr> <p class="sectionHead"><b>Customer Contentment Call List:</b></p> <p class="itemHeadLarge"><#d:[% call_list %]> There <V:is> [% call_lis +t %] <N:person> who <V:is> on the Call List.</p> <hr> [% END %] EOT # Run it Template->new->process (\$template, $data); exit;
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Templating system choice
by Bod (Parson) on Dec 21, 2020 at 10:39 UTC | |
by hippo (Archbishop) on Dec 21, 2020 at 10:53 UTC | |
by Bod (Parson) on Dec 21, 2020 at 11:03 UTC | |
by Your Mother (Archbishop) on Dec 21, 2020 at 16:48 UTC | |
by GrandFather (Saint) on Dec 21, 2020 at 20:08 UTC | |
| |
by hippo (Archbishop) on Dec 21, 2020 at 16:59 UTC | |
| |
by Bod (Parson) on Dec 21, 2020 at 17:13 UTC | |
| |
by Bod (Parson) on Dec 21, 2020 at 19:01 UTC | |
by LanX (Saint) on Dec 23, 2020 at 00:14 UTC | |
by Bod (Parson) on Dec 29, 2020 at 00:12 UTC | |
|
Re^6: Here documents in blocks
by Bod (Parson) on Dec 20, 2020 at 23:25 UTC |