# HG changeset patch # User cin # Date 1361403842 -14400 # Node ID 5d14baa35790a4c203ffbea0a05d72a83fcc0f8e # Parent 7b0dad6117d5e073494bab440276d471c662f6b5 *TTView: fixed template selectors mechanism diff -r 7b0dad6117d5 -r 5d14baa35790 Lib/IMPL/Web/Handler/TTView.pm --- a/Lib/IMPL/Web/Handler/TTView.pm Wed Feb 20 17:24:57 2013 +0400 +++ b/Lib/IMPL/Web/Handler/TTView.pm Thu Feb 21 03:44:02 2013 +0400 @@ -1,6 +1,7 @@ package IMPL::Web::Handler::TTView; use strict; +use Carp qw(carp); use List::Util qw(first); use IMPL::lang; use IMPL::Const qw(:prop); @@ -55,6 +56,15 @@ env => _cached($action->context->{environment}), ImportClass => sub { my $class = shift; + + carp "ImportClass is obsolete use import instead"; + + $class = Loader->safe->Require($class); + + return Factory->new($class); + }, + import => sub { + my $class = shift; $class = Loader->safe->Require($class); @@ -168,6 +178,9 @@ my @selector = @{$rule->{selector}}; my $part = shift @selector; + + # if this rule doesn't have a selector + next unless $part; if ($part->{any}) { #keep the rule for the next try @@ -176,9 +189,6 @@ $part = shift @selector while $part->{any}; } - # if this rule doesn't have a selector - next unless $part; - my $newRule = { selector => \@selector, data => $rule->{data}, diff -r 7b0dad6117d5 -r 5d14baa35790 Lib/IMPL/Web/View/TTDocument.pm --- a/Lib/IMPL/Web/View/TTDocument.pm Wed Feb 20 17:24:57 2013 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Thu Feb 21 03:44:02 2013 +0400 @@ -54,7 +54,10 @@ $require = sub { my $control = shift; - carp("Cant load control $control outside the rendering procedure") unless $self; + unless($self) { + carp("Cant load control $control outside the rendering procedure"); + return; + } if (my $factory = $controls{$control}) { return $factory; @@ -89,8 +92,7 @@ $documentContext = _clone_context( $this->context ); $this->context->stash->set(require => $require); - $this->context->stash->set(document => sub { $self }); - + $this->context->stash->set(document => sub { $self }); my $text = eval { diff -r 7b0dad6117d5 -r 5d14baa35790 Lib/IMPL/Web/View/TTFactory.pm --- a/Lib/IMPL/Web/View/TTFactory.pm Wed Feb 20 17:24:57 2013 +0400 +++ b/Lib/IMPL/Web/View/TTFactory.pm Thu Feb 21 03:44:02 2013 +0400 @@ -45,6 +45,11 @@ sub MergeParameters { my ($this,$name,$refProps) = @_; + if (ref $name) { + $refProps = $name; + $name = (ref $refProps eq 'HASH' and ($refProps->{name} || $refProps->{id})) || '*anonymous*'; + } + my $base = $this->base; $this->context->localise();