comparison Lib/IMPL/Web/View/TTView.pm @ 359:833e663796c4

TTView: added view variable to pass rendering context between controls TTView: display function renamed to display_for WebResource: resources now marked with roles for searching a desired resource by a role in the resource chain
author sergey
date Mon, 25 Nov 2013 02:19:31 +0400
parents 9330835535b9
children d5c8b955bf8d
comparison
equal deleted inserted replaced
358:248f95c1762a 359:833e663796c4
1 package IMPL::Web::View::TTView; 1 package IMPL::Web::View::TTView;
2 use strict; 2 use strict;
3 3
4 use IMPL::lang qw(hashMerge); 4 use JSON;
5 use IMPL::lang qw(hashMerge is);
5 use IMPL::Const qw(:prop); 6 use IMPL::Const qw(:prop);
6 use IMPL::declare { 7 use IMPL::declare {
7 require => { 8 require => {
8 Context => 'IMPL::Web::View::TTContext' 9 Context => 'IMPL::Web::View::TTContext',
10 Loader => 'IMPL::Code::Loader'
9 }, 11 },
10 base => [ 12 base => [
11 'IMPL::Object' => undef, 13 'IMPL::Object' => undef,
12 'IMPL::Object::Autofill' => '@_', 14 'IMPL::Object::Autofill' => '@_',
13 'IMPL::Object::Serializable' => undef 15 'IMPL::Object::Serializable' => undef
42 return $ctx->invoke_environment( 44 return $ctx->invoke_environment(
43 sub { 45 sub {
44 return shift->render( 46 return shift->render(
45 $layout, 47 $layout,
46 hashMerge( 48 hashMerge(
47 $args,
48 { 49 {
49 content => sub { 50 content => sub {
50 $ctx->invoke_environment( 51 $ctx->invoke_environment(
51 sub { 52 sub {
52 return shift->display_model($model,$template,$args); 53 return shift->display_model($model,$template);
53 }, 54 },
54 { 55 {
55 base => $this->viewBase 56 base => $this->viewBase
56 } 57 }
57 ) 58 )
65 } 66 }
66 ); 67 );
67 } else { 68 } else {
68 return $ctx->invoke_environment( 69 return $ctx->invoke_environment(
69 sub { 70 sub {
70 return shift->display_model($model,$template,$args); 71 return shift->display_model($model,$template);
71 }, 72 },
72 { 73 {
73 base => $this->viewBase 74 base => $this->viewBase
74 } 75 }
75 ); 76 );
76 } 77 }
77 },hashMerge( 78 },hashMerge(
78 { 79 $this->globals,
79 includes => scalar($this->includes), 80 hashMerge(
80 tt_ext => $this->tt_ext, 81 $args,
81 document => {}, 82 {
82 debug => sub { 83 includes => scalar($this->includes),
83 warn @_; 84 tt_ext => $this->tt_ext,
85 debug => sub {
86 warn @_;
87 },
88 is => sub {
89 return is(shift,shift);
90 },
91 import => sub {
92 return Loader->safe->Require(shift);
93 },
94 toJSON => sub {
95 return JSON->new()->utf8->pretty->encode(shift);
96 }
84 } 97 }
85 }, 98 )
86 $this->globals
87 ) 99 )
88 ); 100 );
89 } 101 }
90 102
91 1; 103 1;