Mercurial > pub > Impl
diff Lib/IMPL/Web/View/TTDocument.pm @ 345:72799d1211c5
sync
author | cin |
---|---|
date | Fri, 27 Sep 2013 16:28:27 +0400 |
parents | f1d67615a5b1 |
children |
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm Mon Sep 23 00:09:26 2013 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Fri Sep 27 16:28:27 2013 +0400 @@ -21,12 +21,6 @@ $ctx ||= Template::Context->new(); return $template, $ctx, $vars; # context } - ], - props => [ - layout => PROP_RW, - layoutBase => PROP_RW, - registry => PROP_RW, - baseLocation => PROP_RW ] }; @@ -35,22 +29,26 @@ $this->layout( $template->layout ) unless $this->layout; $this->title( $template->title ) unless $this->title; - my $doc = $this; - weaken($doc); - $this->registry->context->stash->update({ - document => sub { $doc } - }); } sub Render { my ($this,$args) = @_; + + my $ctx = $this->context; $args ||= {}; $args->{document} = $this; + $args->{render} = sub { + my ($model,$factory) = @_; + + $factory = $ctx->require($factory) unless is($factory,TTFactory); + + return $factory->new({document => $this, model => $model})->Render(); + }; if ($this->layout) { - my $layout = $this->registry->Require(join('/',$this->layoutBase, $this->layout))->new(); + my $layout = $this->registry->Require($this->layout)->new(); my $next = $this->next::can(); @@ -124,19 +122,21 @@ @startuml -namespace IMPL::Web::View { +object "doc: TTDocument" as doc +object "docCtx: TTContext" as docctx +object "factory: TTFactory" as factory +object "registry: TTRegistry" as registry +object "control: TTControl" as ctl +object "ctlCtx: TTContext" as ctlctx - TTDocument "0 .. *" .. TTLoader - TTDocument --|> TTControl - - TTControl .. TTContext - - TTFactory -- TTControl - TTFactory .. TTContext - - class TTRegistry - -} +doc -up-> docctx +registry --> "0..*" factory +factory .> doc: <<creates>> +factory .up.> ctl: <<creates>> +docctx -up-> registry +ctl -> ctlctx +ctlctx --> registry +ctlctx --> doc @enduml