Zacząłem dzisiaj pisać własny parser szablonów... Wszystko chodzi spoko, oprócz obsługi pętli

{loop {zmienna}} #KOD JAKIS# {/loop}
w jednej lini, ponieważ nie potrzebuję wieloliniowych bloków z pętlami.
Ma ktoś jakiś pomysł jak to poprawić :?:

Pozdrawiam, Paweł
btw, klasa rozszerza abstrakcyjną klasę w której są zmienne i metody (będę robił więcej widoków

konstruktor jest prywatny, ponieważ chcę mieć tylko jedną instancję tej klasy!
<?php require_once('abstract.view.php'); class html extends ab_view { private function __construct() { } public function assign($name, $value) { $this->_res[$name] = $value; return true; } public function setDir($dir) { $this->_dir = $dir; } public function setFile($name) { $this->_file = $name; } public function parse($show_errors = false) { $this->_show_errors=$show_errors; $this->_parsed = $this->_parse($this->_getFileContent()); $this->_is_parsed = true; return true; } private function _getDir() { return $this->_dir.'/'; } private function _getFile() { return $this->_file; } private function _getPath() { return $this->_getDir().$this->_getFile(); } private function _parse($what, $show_errors = false) { /* PETLE */ $foreach_patt = '/{loop \({(.*)}\)}(.*){\/loop}/e'; /* RESZTA ZMIENNYCH */ $pattern = '/{[a-zA-Z\_]+}/e'; return $this->_parsed; } private function petle($a1, $a2, $a3) { foreach($tabl[1] as $key => $value) { } return $a; } private function replace($txt) { $show_errors = $this->_show_errors; return $this->_res[$txt]; } else { if($show_errors) return 'Nie przypisane <b> '.$txt.' </b>!'; } } private function _getFileContent() { } public function show($show_errors=false) { if(!$this->_is_parsed) $this->parse($show_errors); } if(is_a($_this_is_html_view, 'html')) return $_this_is_html_view; else return new html(); } } ?>
------------------------------
Nikt nie ma pomyslu :?:

A moze zrobic to jako
Kod
{section={zmianna}} KOD {/section}
(a odwolania do tabeli to {zmienna.klucz}.... bede bardzo wdzieczny za pomoc
