php - Slim framework with raintpl -


i have existing project uses raintpl3 template engine. trying port slim framework 2.
q1 : there way make slim use $tpl object render views (via di or other similar approach).

i have managed hack way configure create template object within external function should return content slim should echo. earlier not configure tpl configured in init file. when use $tpl->draw('index'); saying template index not found. q2: why can't find template ?

: my_app_root_/public/index.php

require_once "../init.php";  # fire app $app = new slim\slim();  $app->get('/', function(){echo myns\router\apidefault::showhome();});  $app->get('/hello', function() {     echo "get route working."; }); # run slim application $app->run(); 

: my_app_root_/routes/apidefault.php

<?php namespace myns\router;    class apidefault {      private function __construct( $argument)     {         throw new \exception("error constructor not allowed", 1);      }       public static function showhome()     {          $tpl = new \rain\tpl();           $tpl->assign('name','abhinav');         $a = $tpl->draw('index',$return_string = true);         return $a;     } } 

index.tpl stored in my_app_root_/templates/ .

  1. you make own view script wraps template engine. slim did twig , smarty here (only slim 2).

  2. it looks never set directory search templates, wrong? if go own view plugin take param in constructor or something.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -