问题
$view->start();
$view->render("products", "list");
$view->finish();
above is show how to render from a file, I wonder is it possible to render a string/code with this method?
$view->start();
$view->renderstring("<?php echo $this->url->get('users/list') ?>");
$view->finish();
回答1:
You can use 'setContent' to set the view content:
$view->setContent('<h1>hello</h1>');
But this functions receives the final content to the view. So to do the example you gave the correct use would be:
$output = 'The link is: <a href="'.$this->url->get('users/list').'">link</a>';
$this->view->setContent( $output );
echo $this->view->getContent();
来源:https://stackoverflow.com/questions/18486217/how-to-render-code-in-phalcon-view