Inline::Mason::OO - Inline OO Mason
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 %>
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?
__NIFTY__ <% $ARGS{lang} %> is nifty!
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 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__
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.
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 an external file manually and explicitly.
my $m = new MY::Mason; $m->load_file('external_mason.txt');
Inline::Mason
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
To install Inline::Mason, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Inline::Mason
CPAN shell
perl -MCPAN -e shell install Inline::Mason
For more information on module installation, please visit the detailed CPAN module installation guide.