This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.010; | |
use MooseX::Declare; | |
class Blarg | |
{ | |
use MooseX::NonMoose; | |
use Template::Declare::Tags('HTML'); | |
extends 'Template::Declare'; | |
method foo(ClassName $class: Int $thing) { div { p { "My thing is: $thing" } } } | |
around foo(ClassName $class: Int $thing) { div { attr { class => 'wrapper'}; $class->$orig($thing); } } | |
template foo => \&foo | |
} | |
Template::Declare->init( dispatch_to => ['Blarg'] ); | |
say Template::Declare->show( 'foo', 2 ); | |
__END__ | |
produces: | |
<div class="wrapper"> | |
<div> | |
<p>My thing is: 2</p> | |
</div> | |
</div> |
What this will buy me is a more sane wrapper strategy with role application. I'd rather have 'around' keywords than the insanity that is TD's create_wrapper stuff. But mainly, I want type constraint checking that comes with MooseX::Method::Signatures. In the end, this is win. This lets me step back a little bit from TD, write some sanity, and then hook it up to the dispatcher via the template() function.
Granted it is a little unwieldy at first, but I am thinking I could distill this out into it's own thingy. We will see as the week progresses.
Hi, I have a couple jobs that I would like to advertise on your site or via an email list to inform your readers about Perl programming jobs. Please get back to me as soon as you get a chance.
ReplyDeleteLook forward to hearing from you.
Chris
email
ReplyDeletecrose@enticelabs.com