shorter syntax to method calls in catalyst tt views

This commit is contained in:
espie 2006-11-06 13:00:43 +00:00
parent 3766439373
commit e2ad9a4e76
4 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# $OpenBSD: Makefile,v 1.1.1.1 2006/11/06 13:00:43 espie Exp $
COMMENT= "use shorter names in catalyst tt views"
DISTNAME= Catalyst-View-TT-FunctionGenerator-0.01
PKGNAME= p5-${DISTNAME}
CATEGORIES= textproc perl5 devel
# Artistic + GPL
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=Catalyst/}
RUN_DEPENDS= ::textproc/p5-Catalyst-View-TT \
::www/p5-Catalyst-Plugin-Singleton
REGRESS_DEPENDS=${RUN_DEPENDS} \
::devel/p5-Test-Pod \
::devel/p5-Test-Pod-Coverage
MAKE_ENV= TEST_POD=Yes
CONFIGURE_STYLE=perl
PKG_ARCH= *
.include <bsd.port.mk>

View File

@ -0,0 +1,4 @@
MD5 (Catalyst-View-TT-FunctionGenerator-0.01.tar.gz) = 375548dca6f4911ea09852bbda1631c7
RMD160 (Catalyst-View-TT-FunctionGenerator-0.01.tar.gz) = 0c7609db85b2d87b0fd79e7de5f9b04777aa30d7
SHA1 (Catalyst-View-TT-FunctionGenerator-0.01.tar.gz) = 84a4c51346bad78ecb4d2d0d76f4681f2ba92528
SIZE (Catalyst-View-TT-FunctionGenerator-0.01.tar.gz) = 5256

View File

@ -0,0 +1,25 @@
This plugin should usually be invoked from an end action in your Application.
Call generate_functions to create the code references shortcuts to the
methods used in the template toolkit view.
Then enjoy the shorter syntax.
For instance:
sub action : Local {
my ( $self, $c ) = @_;
$c->view("ViewName")->generate_functions('prototype');
# OR
$c->view("ViewName")->generate_functions($c->prototype);
# OR
$c->view("ViewName")->generate_functions([$c, 'uri_for']);
}
# In your template, we can now have:
[% link_to_remote("foo", { url => uri_for("blah") } ) %]
# instead of saying this:
[% c.prototype.link_to_remote("foo", { url => c.uri_for("blah") } ) %]

View File

@ -0,0 +1,5 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2006/11/06 13:00:43 espie Exp $
${P5SITE}/Catalyst/View/
${P5SITE}/Catalyst/View/TT/
${P5SITE}/Catalyst/View/TT/FunctionGenerator.pm
@man man/man3p/Catalyst::View::TT::FunctionGenerator.3p