# NAME

Catalyst::View::Template::Lace - Catalyst View Adaptor for Template::Lace

# SYNOPSIS

Define a View:

    package  MyApp::View::User;

    use Moo;
    extends 'Catalyst::View::Template::Lace';

    has [qw/age name motto/] => (is=>'ro', required=>1);

    sub template {q[
      <html>
        <head>
          <title>User Info</title>
        </head>
        <body>
          <dl id='user'>
            <dt>Name</dt>
            <dd id='name'>NAME</dd>
            <dt>Age</dt>
            <dd id='age'>AGE</dd>
            <dt>Motto</dt>
            <dd id='motto'>MOTTO</dd>
          </dl>
        </body>
      </html>
    ]}

    sub process_dom {
      my ($self, $dom) = @_;
      $dom->dl('#user', +{
       age=>$self->age,
       name=>$self->name,
       motto=>$self->motto});
    }

    1;

Used in a controller:

    package MyApp::Controller::User;

    use Moose;
    use MooseX::MethodAttributes;
    extends 'Catalyst::Controller';

    sub display :Path('') {
      my ($self, $c) = @_;
      $c->view('User',
        name => 'John',
        age => 42,
        motto => 'Why Not?')
      ->http_ok;
    }

    __PACKAGE__->meta->make_immutable;

# DESCRIPTION

**NOTE** I consider this an early access release.  Code and API here is subject
to significant change as needed to advance the project.  Please don't use this
in production unless you are willing to cope with that.

[Catalyst::View::Template::Lace](https://metacpan.org/pod/Catalyst::View::Template::Lace) is a view adaptor for [Template::Lace](https://metacpan.org/pod/Template::Lace) with
some [Catalyst](https://metacpan.org/pod/Catalyst) specific helpers and features added.  Reviewing documentation
for [Template::Lace](https://metacpan.org/pod/Template::Lace) would useful in furthering your ability to use it in
[Catalyst](https://metacpan.org/pod/Catalyst).

In short, this is a template framework for [Catalyst](https://metacpan.org/pod/Catalyst) that introduces strongly
typed views and view components as design patterns for your web applications.
What this means is that unlike most [Catalyst](https://metacpan.org/pod/Catalyst) views that you're probably
familiar with (such as the Template::Toolkit view) we define one view per
template instead of one view for all the templates.  Although this might seem
like a lot of views to write the upside is by defining a strong interface for your
view, you eliminate a host of display errors that I commonly see in the wild since
there is no contract beween a view and the controller that is calling it.  Also
since each component in your view has access to the [Catalyst](https://metacpan.org/pod/Catalyst) context, you can
write smarter views with display logic properly encapsulated near the template
code it will actually be used.  This reduces complexity in your controllers and
makes it easier to solve complex layout logic.

After reviewing these documentation you can advance to [Catalyst::View::Template::Lace::Tutorial](https://metacpan.org/pod/Catalyst::View::Template::Lace::Tutorial)
and you might find the test cases in the `/t` directory of this distribution
handy as well.

**NOTE** I consider current documentation to be the 'thin red line' requirement
for CPAN publication but there's tons more to be done.  Critique and contributions
very welcomed!.

# CONFIGURATION

This component defines the following configuration options:

## factory

These specifies which subclass of [Template::Lace::Factory](https://metacpan.org/pod/Template::Lace::Factory) will be used to
manage your view lifecycle.  The default is [Catalyst::View::Template::Lace::Factory](https://metacpan.org/pod/Catalyst::View::Template::Lace::Factory).
You can also specify [Catalyst::View::Template::Lace::PerContext](https://metacpan.org/pod/Catalyst::View::Template::Lace::PerContext) or write your
own.  See documentation for the two options for more.

## model\_class

## render\_class

## init\_args

## model\_constructor

## component\_handlers

All these are pass through configuration to the underlying subclass of
[Template::Lace::Factory](https://metacpan.org/pod/Template::Lace::Factory) which you should review.

# AUTHOR

John Napiorkowski [email:jjnapiork@cpan.org](email:jjnapiork@cpan.org)

# SEE ALSO

[Template::Lace](https://metacpan.org/pod/Template::Lace), [Catalyst::View::Template::Pure](https://metacpan.org/pod/Catalyst::View::Template::Pure)

# COPYRIGHT & LICENSE

Copyright 2017, John Napiorkowski [email:jjnapiork@cpan.org](email:jjnapiork@cpan.org)

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