示例#1
0
 /**
  * (non-PHPdoc)
  * @see Ding\Mvc.IViewRender::render()
  */
 public function render(View $view)
 {
     /**
      * @todo is there a better way to do this?
      */
     global $modelAndView;
     $modelAndView = $view->getModelAndView();
     require_once 'Twig' . DIRECTORY_SEPARATOR . 'Autoloader.php';
     \Twig_Autoloader::register();
     $loader = new \Twig_Loader_Filesystem(dirname($view->getPath()));
     $twig = new \Twig_Environment($loader, array($this->_twigOptions));
     $template = $twig->loadTemplate(basename($view->getPath()));
     echo $template->render(array('vars' => $modelAndView->getModel()));
 }
示例#2
0
 /**
  * (non-PHPdoc)
  * @see Ding\Mvc.IViewRender::render()
  */
 public function render(View $view)
 {
     /**
      * @todo is there a better way to do this?
      */
     global $modelAndView;
     $modelAndView = $view->getModelAndView();
     require_once 'Smarty.class.php';
     $smarty = new \Smarty();
     $smarty->template_dir = dirname($view->getPath());
     $smarty->compile_dir = $this->_smartyOptions['compile_dir'];
     $smarty->config_dir = $this->_smartyOptions['config_dir'];
     $smarty->cache_dir = $this->_smartyOptions['cache_dir'];
     $smarty->debugging = $this->_smartyOptions['debugging'];
     foreach ($modelAndView->getModel() as $key => $value) {
         $smarty->assign($key, $value);
     }
     $smarty->display(basename($view->getPath()));
 }
示例#3
0
 /**
  * (non-PHPdoc)
  * @see Ding\Mvc.IViewRender::render()
  */
 public function render(View $view)
 {
     /**
      * @todo is there a better way to do this?
      */
     global $modelAndView;
     $modelAndView = $view->getModelAndView();
     /**
      * @todo render headers: does this belong here?
      */
     $objects = $modelAndView->getModel();
     if (isset($objects['headers'])) {
         foreach ($objects['headers'] as $header) {
             header($header);
         }
     }
     // Now render everything else.
     if (file_exists($view->getPath())) {
         include_once $view->getPath();
     }
 }
示例#4
0
文件: HttpView.php 项目: im286er/Ding
 /**
  * Constructor.
  *
  * @param ModelAndView $modelAndView Use this model representation for this view.
  * @param string       $path         Full absolute path to the file containing this view.
  *
  *  @return void
  */
 public function __construct(ModelAndView $modelAndView, $path)
 {
     parent::__construct($modelAndView);
     $this->_path = $path;
 }