NAME

Inline::Mason::OO - Inline OO Mason

SYNOPSIS

MY::Mason file:

package MY::Mason;
use Inline::Mason::OO;  # __CARDINALS__ will automatically loaded.
# or
# use Inline::Mason::OO qw(no_autoload);
# to escape from loading __CARDINALS__
our @ISA = qw(Inline::Mason::OO);

1;
__END__

__CARDINALS__
% my @cardinals = qw(eins zwei drei);
<% join q/ /, @cardinals %>

My perl script:

use MY::Mason
my $m = new MY::Mason ('t/external_mason');
print $m->HELLO();
print $m->NIFTY(lang => 'Perl');
print $m->CARDINALS();



__END__

__HELLO__
% my $noun = 'World';
Hello <% $noun %>!
How are ya?

t/external_mason

__NIFTY__
<% $ARGS{lang} %> is nifty!

DESCRIPTION

This module extends the power of Inline::Mason to an OO level. You may use it to build a module specific for generating documents, like help documentation, etc.

ON IMPORTING

On importing the module, by default, the inline-mason will be loaded. However, you can still pass 'no_autoload' stating that you don't want the module to automatically load inline-mason scripts dwelling in the module file.

use Inline::Mason::OO qw(no_autoload);

Besides, you can call 'to_load_files' in the parent module, and the files will be loaded every time when you instantiate a new object.

package MY::Mason;
use Inline::Mason::OO;
our @ISA = qw(Inline::Mason::OO);
Inline::Mason::OO::to_load_files(@files);

1;
__END__

And, of course, you can do this superfluous and redundant action.

package MY::Mason;
use Inline::Mason::OO qw(no_autoload);
our @ISA = qw(Inline::Mason::OO);
Inline::Mason::OO::to_load_files(__FILE__);

1;
__END__

METHODS

new

The constructor takes a list of file's names in which mason scripts reside and will load them to the instance. The file where the constructor is called is always loaded by default.

load_mason

Create mason scripts in place, and you can pass a list of pairs.

Load mason script in place:

my $m = new MY::Mason;
$m->load_mason
(
 BEATLES
 =>
 'Nothing\'s gonna change my <% $ARGS{what} %>',
 # ... ... ...
 );

print $m->BEATLES(what => 'world');

load_file

Load an external file manually and explicitly.

my $m = new MY::Mason;
$m->load_file('external_mason.txt');

SEE ALSO

Inline::Mason

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Yung-chung Lin (a.k.a. xern) <xern@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself