Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Totally Simple Templates

by japhy (Canon)
on Jan 24, 2001 at 06:14 UTC ( #53860=sourcecode: print w/replies, xml ) Need Help??
Category: Text Processing
Author/Contact Info Jeff japhy Pinyan
Description: Using my recently uploaded module, DynScalar, template woes are a thing of the past. By wrapping a closure in an object, we have beautiful Perl code expansion.
The following is an over-simplified example.

# coming to your CPAN mirror soon
use DynScalar 'newTemplate';
use strict;
use vars '$data';  # has to be package var

my $template = newTemplate {
  my $out = << "END";

Hello, <b>$data->{USER}</b>.  You've been here
$data->{COUNT} times.



  for (@{ $data->{NODES} }) {
    $out .= qq{<li> <a href="$_->{href}">$_->{name}</a>\n};

  $out .= "</ul>\n";


$data = getInfo(magically_determine_user());
print HTML_page($template);
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://53860]
[LanX]: new Firefox + cb sidebar do random auto expand on submit
[LanX]: probably need to start pm discussion
[LanX]: they have a constitutional referendum in turkey, kind of "do you want a dictator" and everybody opting no gets problems ...
[Corion]: LanX: Random Auto Expand?
[Corion]: LanX: Well, everybody opting "yes" will also get problems. The question is more like "Do you want problems now or problems later?"
[LanX]: and the AA had posters with a big say NO with a small "to alcohol"
[ambrus]: LanX: is it the kind of free and secret vote where there's only one box you can check?
[LanX]: no two boxes , enemies of the state are just denounced

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-03-27 12:18 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.