InlineWeb
Anonymous Monk
created: 2006-01-24 16:49:50
#!/usr/bin/perl
########## InlineWeb.pm
package InlineWeb;
use Filter::Simple;
FILTER{
my $program="";

while (1){
  if (/\G{{/gc){
    /\G({+)/gc;
    my $braces = $1;
    $braces=~tr/{/}/;
    /\G(.*?)}}$braces/gcs;
    $program.=$1.qq[;\n];
    next;
  }elsif (/\G{\[/gc){
    /\G(\[+)/gc;
    my $sq = $1;
    $sq=~tr:\[:\]:;
    /\G(.*?)$sq]}/gcs;
    $program.=q[print scalar ].$1.qq[;\n];
    next;
  }else{
    /\G(.*?)(?=({\[|{{|$))/gcs;
    my $txt = $1;
    my $delim = $2;
    $txt=~s:':\\':g;
    $program.=q[print '].$txt.qq[';\n];
    next if $delim;
  }
  last;
}
$_=$program;
return $done=1;
};
1;
Re: InlineWeb
created: 2006-01-24 16:58:43

This code can handle simple substituions, but how do you handle conditions and loops? Includes? Nested wrappers? Most of the work i deal with involves database lookups and displaying rows of information, which is why i turn to modules such as Template-Toolkit, HTML::Mason, and HTML::Template.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
Re^2: InlineWeb
created: 2006-01-25 17:58:16
Yep, it works. Try:
{{
for (@array){
}}
{[$_]}
{{
}
}}
Re: InlineWeb
created: 2006-01-25 10:38:07
You should be interested in PLP.
Re: InlineWeb
created: 2006-01-25 19:24:19

Makeshifts last the longest.

perlmonks.org content © perlmonks.org and Anonymous Monk, Aristotle, jeffa, wazoox

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03