What are your templating strategies?

后端 未结 5 530
感情败类
感情败类 2020-12-16 07:36

I try to develop my own little framework. For this, I\'d like to read up some templating techniques. I know that templating is a really complex topic, but knowing some strat

5条回答
  •  长情又很酷
    2020-12-16 07:55

    I really enjoyed zend-framework approach to this, and have used it myself in our framework. You will have a view class with will have things like:

    $view = new View();
    $view->setTemplatesPath('.....');
    $view->assign('name','value');
    $view->render('index');
    

    the render method will take all the variables stored and make them properties and include the template based on the Path set, so in your templates you will have:

    foo; ?>
    ....
    load('header'); // this includes another template ?>
    

提交回复
热议问题