I am trying to "include" a FormAPI function in my tpls using <iw_include pt="path/to/formapi/function.tpl"/> , but the calling page does not seem to have access. Is there any way around this?
Specifically what Im trying to do is call a function that strips white space from the output file (generated by templating) and not have to copy and paste this function every time I want to make a change. I know I can createa Perl module out of it but I dont have root access, dont have time to spend learning how to createa my own perl module, and am looking for a simple solution. Here is some sample code (the parse_page function is what I want to make "shared" via the iw_include):
<iw_perl><![CDATA[
sub parse_page {
my $data = $_;
# Strip all whitespace from the front of the doc.
$data =~ s/(\s*?)</</;
$data =~ s/\t//g;
# Strip anything after </html>
$data =~ s/<\/html>(.*)/<\/html>\n/s;
my
@lines = split(/\n/,$data);
$data = "";
foreach my $line (
@lines) {
if(length($line) > 0) {
$data="$data$line\n";
}
}
$_ = $data;
}
]]></iw_perl>
<iw_ostream filter="parse_page()">
tpl code goes here.....
</iw_ostream>
The contents of the include file would be everything inbetween the <iw_perl> tags including the tags themselves.
Mike