NAME

Catalyst::View::Template::Declare - Use Template::Declare with Catalyst

VERSION

Version 0.00_03

SYNOPSIS

Create the view:

myapp_create.pl view TD Template::Declare

Add templates in MyApp::View::TD::<name>:

package MyApp::View::TD::Test;
template foo => sub { html {} };
template bar => sub {   ...   };
1;

Then use the templates from your application:

$c->stash(template => 'foo');
$c->detach('View::TD');

You can get at the Catalyst context via the <c> package:

template foo => sub { "This is the ". c->action. " action." };
template bar => sub { "Hello, ". c->stash->{world} };

Have fun. This is all very experimental.

DESCRIPTION

Very experimental.

Make a view:

package MyApp::View::TD;
use base 'Catalyst::View::Template::Declare';
use Template::Declare::Tags;
 
template foo => sub { 
    html { 
        head { title { c->stash->{title} } };
        body { "Hello, world" }
      }
};

In your app:

$c->stash(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 also 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 foo => sub { ... };
1;

Then you can set $c->stash(template => 'foo') and everything will work as you expect.

METHODS

process

Render the template specified by the action or $c->stash->template.

render($c, $template)

Render the template named by $template and return the text.

COMPONENT

Private

AUTHOR

Jonathan Rockway, <jrockway at cpan.org>

BUGS

Please report any bugs or feature requests to bug-catalyst-view-template-declare at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-View-Template-Declare. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Visit #catalyst on irc.perl.org, submit an RT ticket, or send me an e-mail.

ACKNOWLEDGEMENTS

Template::Declare

Jifty

COPYRIGHT & LICENSE

Copyright 2007 Jonathan Rockway, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.