Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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
CPAN ID: PINYAN
japhy@pobox.com
http://www.pobox.com/~japhy/
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.
#!/usr/bin/perl

# coming to your CPAN mirror soon
# http://www.pobox.com/~japhy/modules/
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.

<br><br>

<ul>
END

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

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

  $out;
};

$data = getInfo(magically_determine_user());
print HTML_page($template);

Comment on Totally Simple Templates
Download Code

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://53860]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2015-08-04 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (59 votes), past polls