Exemplo n.º 1
0
 public function saludo($nombre)
 {
     //        View::set("name", $nombre);
     //        View::set("title", "Custom MVC");
     //        View::render("front\\home");
     $templates = new Engine('../src/App/Views/front/');
     echo $templates->render('error', ['name' => 'Jonathan']);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function render($template, $value)
 {
     //Performance: if there are no '%' fallback to Engine
     if (strstr($template, '%') == false) {
         return parent::render($template, $value);
     }
     $result = $template;
     if (!is_array($value)) {
         $value = array('' => $value);
     }
     foreach (new NestedKeyIterator(new RecursiveArrayOnlyIterator($value)) as $key => $value) {
         $pattern = "/" . $this->left . $key . "(%[^" . $this->right . "])?" . $this->right . "/";
         preg_match_all($pattern, $template, $matches);
         $substs = array_map(function ($match) use($value) {
             return $match !== '' ? sprintf($match, $value) : $value;
         }, $matches[1]);
         $result = str_replace($matches[0], $substs, $result);
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Renders template.
  * @return void
  * @internal
  */
 public function renderChildTemplate($name, array $params = array())
 {
     $name = $this->engine->getLoader()->getChildName($name, $this->name);
     $this->engine->render($name, $params);
 }
Exemplo n.º 4
0
 public function saludo($nombre)
 {
     $templates = new Engine('../src/App/Views/front/');
     echo $templates->render('error', ['name' => 'Jonathan']);
 }