Example #1
0
 /**
  * Get email template and load view with params
  *
  * @param string $name View name to load
  * @param array $params Params to send to the view
  * @return string
  */
 public function getTemplate($name, $params = [])
 {
     // Prepare view service
     $view = new View();
     $view->setViewsDir(__ROOT__ . '/app/views/');
     $view->setMainView('email');
     // Options for Sleet template engine
     $sleet = new Sleet($view, Di::fetch());
     $sleet->setOptions(['compileDir' => __ROOT__ . '/app/tmp/sleet/', 'trimPath' => __ROOT__, 'compile' => Compiler::IF_CHANGE]);
     // Set template engines
     $view->setEngines(['.sleet' => $sleet, '.phtml' => 'Ice\\Mvc\\View\\Engine\\Php']);
     $view->setContent($view->render($name, $params));
     return $view->layout();
 }