making Smarty_Compiler more flexible

From: Date: Tue, 28 Jan 2003 10:32:58 +0000
Subject: making Smarty_Compiler more flexible
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-639@lists.php.net to get a copy of this message
Hi, Some using some advanced features I need to make Smarty_Compiler more flexible. Here a some feature request: 1) Smarty::$compiler_class can be set to anything I like but Smarty tries to load it from SMARTY_DIR with extension ".class.php". That's not really a good solution I think. I would first try to check if the compiler class does not already exists. So the programmer could include his own class manually. Line 1125: if (!class_exists($this->compiler_class)) include_once SMARTY_DIR.$this->compiler_class . '.class.php'; 2) function _compile_template is not flexible enough. I needed to set some more variables of the compiler class which is not possible easily. You need to copy past the whole function to your own Smarty class. Perhaps you could consider instantiating the Compiler in another function Smarty.class.php: function _load_compiler() { if (!class_exists($this->compiler_class)) include_once SMARTY_DIR.$this->compiler_class . '.class.php'; $this->_compiler = new $this->compiler_class; } This way a programmer could override the default _compile_template method this way: MySmarty.class.php: function _compile_template (...) { parent::_compile_template(...); $this->_compiler->foo = $bar; } 3) Perhaps a back-reference in the compiler class to the calling Smarty class whould also be useful. Perhaps you could give the current object to the compiler as parameter: Smarty.class.php: function _load_compiler() { if (!class_exists($this->compiler_class)) include_once SMARTY_DIR.$this->compiler_class . '.class.php'; $this->_compiler = new $this->compiler_class ($this); // <-------- HERE!!! } This could make things even more flexible. Thoughts? André

« previous php.smarty.dev (#639) next »