On Thu, Nov 13, 2008 at 12:37 PM, Ian Sillitoe
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> I was developing some code to help me generate different views for a given
> class and after a few iterations of refactoring I ended up with a Moose Role
> that allows a class to render itself based on an associated Template file. I
> did a quick search and couldn't see anything obvious that already did this -
> anyone have any comments/suggestions?
>
> Cheers,
>
> Ian
>
>
> MODULE
>
> MooseX::Role::TTSelf
>
> SYNOPSIS
>
> Farm/Cow.pm
>
> package Farm::Cow;
> use Moose;
> with 'MooseX::Role::TTSelf';
>
> has 'spots' => ( is => 'rw' );
>
> sub moo { "Mooooooo" }
>
> Farm/Cow.t
>
> This cow has [% self.spots %] spots and goes [% self.moo %]!
>
> Elsewhere on the Farm...
>
> my $cow = Farm::Cow->new( spots => '8' );
>
> $class->render(); # "This cow has 8 spots and goes Mooooooo!"
>
Actually I just released an alpha version of something that could do
exactly this, but I'm using it for a completely different purpose
http://search.cpan.org/src/PERIGRIN/XML-Toolkit-0.02/lib/XML/Filter/Moose/ClassTemplate.pm
-Chris