Re: MooseX::Role::TTSelf

2008-11-14 Thread Hans Dieter Pearcey
On Thu, Nov 13, 2008 at 05:37:27PM +, Ian Sillitoe wrote:
> Farm/Cow.t

.t is probably not a great extension, since most people will associate that
with test files.

.tt or .tt2 are common.

hdp.


Re: MooseX::Role::TTSelf

2008-11-14 Thread Chris Prather
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 { "Mooo" }
>
> 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 Mooo!"
>

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


Re: MooseX::Role::TTSelf

2008-11-13 Thread Ian Sillitoe
Hi Chris,

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
>

Cool - looks pretty similar to the code I've got here. Are you thinking of
factoring this out into a more generic namespace?

Cheers,

Ian



-- 
Dr Ian Sillitoe
CATH Team -- http://cathdb.info

"Advice is what we ask for when we already know
the answer but wish we didn't" -- Erica Jong