Anyone using Mason for standalone scripts

S

Steve

I'm playing around with Mason as a template-parser for standalone
scripts outside of a web environment. If it works well enough, I might
apply the approach toward writing a Mason wrapper so I can use Mason in
shared-hosting environments where I don't have access to Apache httpd.conf.

Anyway, I'm following the example provided in Mason's admin guide, and
have a small standalone script like this:


#!c:/Perl/bin/perl.exe
use HTML::Mason;
use strict;

my $outbuf;
my $interp = HTML::Mason::Interp->new(
comp_root => 'c:/workspace/MyMasonTemplates',
data_dir => 'c:/workspace/MyMasonData',
out_method => \$outbuf
);
$interp->exec( 'test.html' );


However, when I run this script I get the following error:


Component path given to Interp->load must be absolute (was given test.html)


I'm using a relative path in the example above because that's what the
Mason admin manual calls for (that's the whole point of specifying a
"comp_root" value). However, the interesting thing is that the error
message is exactly the same even when I change the parameter to
$interp->exect() to be the absolute path of this filename. Can anyone
who's used Mason in a standalone script environment spot what I might be
missing here?
 
J

Joost Diepenmaat

Steve said:
my $interp = HTML::Mason::Interp->new(
comp_root => 'c:/workspace/MyMasonTemplates',
data_dir => 'c:/workspace/MyMasonData',
out_method => \$outbuf
);
$interp->exec( 'test.html' );
Component path given to Interp->load must be absolute (was given
test.html)
specifying a "comp_root" value). However, the interesting thing is
that the error message is exactly the same even when I change the
parameter to $interp->exect() to be the absolute path of this
filename. Can anyone who's used Mason in a standalone script
environment spot what I might be missing here?

If the path is relative to comp_root,

$interp->exec( '/test.html' );

might work.

/untested, it's been years since I've used Mason/

Joost.
 
S

Steve

$interp->exec( '/test.html' );


What do you know... it really was that simple. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top