Hello Monks!
After a long hiatus from the site, I'm back again :)
I've been toying with a side pet project for publishing HTML files. What I'm trying to achieve is similar to what ActionView, and other templating tools do.
In publish.pl, let's say I have a subroutine 'layout' that has local variables $headline, $body, $url. Within this sub, I'd like to call another script 'article.layout.pl', but with the local variables $headline, $body, and $url available to the script. 'article.layout.pl' would then use these variables to print out the final layout.
In publish.pl
sub layout { ... my ($headline, $body, $url); ... # call article.layout.pl ??? article.layout.pl {$headline, $body, $url}; }
In article.layout.pl
print <<HEADER ... HEADER print $title; print $body; print $url; print <<FOOTER ... FOOTER
I realize I could use TemplateTookit to achieve this, but I was hoping to learn how to call mess with perl scoping in general.
Thanks fellow monks! It's good to be back.
In reply to Injecting local variables into a template by MistaMuShu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |