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


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[
          <title>User Info</title>
          <dl id='user'>
            <dd id='name'>NAME</dd>
            <dd id='age'>AGE</dd>
            <dd id='motto'>MOTTO</dd>

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


Used in a controller:

    package MyApp::Controller::User;

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

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


A Template may also contain components which are reusable blocks of template functionality and which refer to other Catalyst Views in your application:

    <view-master title='Homepage'>
      <view-header navbar_section='home'/>
          <p>You are doomed to discover you can never recover from the narcolyptic
          country in which you once stood, where the fires alway burning but there's
          never enough wood</p>
      <view-footer copyright='$.copy' />

Such components can wrap your main content or even other component, and they can accept arguments. See Catalyst::View::Template::Lace::Tutorial for more details.


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 is a view adaptor for Template::Lace with some Catalyst specific helpers and features added. Reviewing documentation for Template::Lace would useful in furthering your ability to use it in Catalyst.

In short, this is a template framework for Catalyst that introduces strongly typed views and view components as design patterns for your web applications. What this means is that unlike most 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 with existing views since there is no contract beween a view and the controller that is calling it. For example a typo in setting the stash can turn into a hard to track down bug in the template. Also since each component in your view has access to the 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 this documentation you can advance to 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!.


This component defines the following configuration options:


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






All these are pass through configuration to the underlying subclass of Template::Lace::Factory which you should review.


John Napiorkowski


Template::Lace, Catalyst::View::Template::Pure


Copyright 2017, John Napiorkowski

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