示例#1
0
 function __construct(Route $route, User $user, $file = null, $vars = null, $devTemplate = true, $devJs = true, $devCss = true, $devImg = false, Di $di, $httpMtime = false, $httpEtag = false, $httpExpireTime = false)
 {
     parent::__construct($file, $vars, $devTemplate, $devJs, $devCss, $devImg, $di, $httpMtime, $httpEtag, $httpExpireTime);
     $this['route'] = $route;
     $this['user'] = $user;
     $this->onCompile(function ($tml) use($route) {
         $tml('body')->attr(['data-route--root' => $route->rootUrl(), 'data-route--branch' => '<?=$route->branchUrl()?>', 'data-route--id' => '<?=$route->branchLevelId()?>', 'data-user--id' => '<?=$user->id?>']);
         $tml('a')->each(function ($a) use($route) {
             $a->href = $route->resolveRoute($a->href);
         });
         $tml('form')->each(function ($a) use($route) {
             $a->action = $route->resolveRoute($a->action);
         });
     });
 }