![]() |
Templating class
Alright, I'm struggling to get a template class (smarty like) going on right here, and I've made it, up to some point. Simple vars, like $a, $some_var, $a_v4r and such are correctly parsed by this simple rule: (variables will look like {$this_is_a_var} in the HTML code)
Code:
$this->output = preg_replace( "/\{\$([a-zA-Z0-9_\-]+?)\}/", '$this->vars[\'\\1\']', $this->output );Code:
$this->output = preg_replace( "/\{\$([a-zA-Z0-9_\-]+?)(\['?(?:[a-zA-Z0-9]+?)'?\])*\}/e", '$this->vars[\'\\1\']\\2', $this->output );Code:
$this->template_vars = array( 'test_var' => 'some sample var',Also, if someone has a little free time & knowledge, please try to respond to the last question of this topic: http://www.talkphp.com/showthread.php?t=1708 It would help me alot. Thanks. |
I can suggest to use php as a template engine. Actually that is reason why php was created. And it works much faster than any template engine.
|
Quote:
|
| All times are GMT. The time now is 12:52 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0