Catalyst::View::Template::DeclareCatalyst::View::Template::Declare is a Perl module that allows you to use Template::Declare with Catalyst. | |
Download |
Catalyst::View::Template::Declare Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Jonathan Rockway
- Publisher web site:
- http://search.cpan.org/~jrockway/
Catalyst::View::Template::Declare Tags
Catalyst::View::Template::Declare Description
Catalyst::View::Template::Declare is a Perl module that allows you to use Template::Declare with Catalyst. Catalyst::View::Template::Declare is a Perl module that allows you to use Template::Declare with Catalyst.SYNOPSISCreate the view: myapp_create.pl view TD Template::DeclareAdd templates in MyApp::View::TD::: package MyApp::View::TD::Test; use Template::Declare::Tags; template foo => sub { html {} }; template bar => sub { ... }; 1;Then use the templates from your application: $c->view('TD')->template('foo'); $c->detach('View::TD');You can get at the Catalyst context via the package: template foo => sub { "This is the ". c->action. " action." }; template bar => sub { "Hello, ". c->stash->{world} };Have fun. This is all somewhat experimental and subject to change.Make a view: package MyApp::View::TD; use base 'Catalyst::View::Template::Declare'; 1;Make a template: package MyApp::View::TD::Root; use Template::Declare::Tags; template foo => sub { html { head { title { c->stash->{title} } }; body { "Hello, world" } } };In your app: $c->view('TD')->template('foo'); $c->stash(title => 'test'); $c->detach('View::TD');And get the output: < html >< head >< title >test< /title >< /head >< body >Hello, world< /body >< /html >You can spread your templates out over multiple files. If your view is called MyApp::View::TD, then everything in MyApp::View::TD::* will be included and templates declared in those files will be available as though they were declared in your main view class.Example: package MyApp::View::TD::Foo; use Template::Declare::Tags; template bar => sub { ... }; 1;Then you can set $c->view('TD')->template('bar') and everything will work as you expect. Requirements: · Perl
Catalyst::View::Template::Declare Related Software