Mercurial > pub > Impl
view Lib/IMPL/Web/View/TTRegistry.pm @ 350:f356c4894d1b
working on TTView: layouts
author | cin |
---|---|
date | Mon, 07 Oct 2013 17:35:54 +0400 |
parents | 72799d1211c5 |
children |
line wrap: on
line source
package IMPL::Web::View::TTRegistry; use strict; use mro; use IMPL::Const qw(:prop); use IMPL::declare { require => { TTFactory => 'IMPL::Web::View::TTFactory', TTControl => '-IMPL::Web::View::TTControl' }, base => [ 'IMPL::Object' => undef ], props => [ context => PROP_RW, _cache => PROP_RW, ] }; sub CTOR { my ($this,$context) = @_; $this->context($context); $this->_cache({}); } sub Require { my ($this,$name) = @_; if(my $factory = $this->_cache->{$name}) { return $factory; } else { my $template = $this->loader->template($name) or die AppException->new("Failed to load a template $name"); $factory = TTFactory->new( $template->class || TTControl, $template, $this->context->clone, $name, $this ); $this->_cache->{$name} = $factory; return $factory; } } 1; __END__ =pod =head1 NAME C<IMPL::Web::View::Registry> - реестр шаблонов документа. =head1 DESCRIPTION Используется для реализации функции C<require> внутри шаблонов. =cut