diff Lib/IMPL/Web/View/TTContext.pm @ 356:97131d500f16

TTView: added identifiers support
author cin
date Thu, 17 Oct 2013 17:48:50 +0400
parents 8dfb9df07d02
children 833e663796c4
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTContext.pm	Thu Oct 17 01:04:37 2013 +0400
+++ b/Lib/IMPL/Web/View/TTContext.pm	Thu Oct 17 17:48:50 2013 +0400
@@ -34,6 +34,7 @@
 	   includes
 	   modules
 	   aliases
+	   id
 	)) {
 		my $t = $prop;
 		
@@ -65,6 +66,14 @@
     return $clone;
 }
 
+sub get_next_id {
+	my ($this) = @_;
+	
+	my $id = $this->stash->get('document.nextId') || 0;
+	$this->stash->set('document.nextId', $id + 1);
+	return "w-$id";
+}
+
 sub find_template {
 	my ($this,$name) = @_;
 	
@@ -267,7 +276,7 @@
        	    }
        	    
        	    if (my $class = $info->{class}) {
-       	    	$class->new($this,$info->{template})->Render($args);
+       	    	$class->new($ctx,$info->{template},$args)->Render($args);
        	    } else {
             	return $ctx->include($info->{template},$args);
        	    }
@@ -276,7 +285,8 @@
 	       $info->{labels} || {},
 		   {
 		   	base => $info->{base},
-		   	parent => $this
+		   	parent => $this,
+		   	id => $this->get_next_id
 		   }
 	   )
 	)
@@ -288,9 +298,9 @@
 	die ArgException->new(prefix => "the prefix must be specified")
 	   unless defined $prefix;
 	
-	#TODO handle DOM models
+
 	
-	if (my $res = $this->stash->get(['resolver', [$this,$prefix,$args]] ) ) {
+	if (my $res = $this->stash->get(['resolve', [$this,$prefix,$args]] ) ) {
 		return $res;
 	}