2015-09-17 23:11:18 -04:00
|
|
|
<?php
|
2015-11-16 11:40:01 -05:00
|
|
|
/**
|
|
|
|
* Ion
|
|
|
|
*
|
|
|
|
* Building blocks for web development
|
|
|
|
*
|
|
|
|
* @package Ion
|
|
|
|
* @author Timothy J. Warren
|
2016-01-04 16:58:33 -05:00
|
|
|
* @copyright Copyright (c) 2015 - 2016
|
2015-11-16 11:40:01 -05:00
|
|
|
* @license MIT
|
|
|
|
*/
|
2015-09-17 23:11:18 -04:00
|
|
|
|
|
|
|
namespace Aviat\Ion\View;
|
|
|
|
|
|
|
|
use Aviat\Ion\View\HttpView;
|
|
|
|
use Aviat\Ion\Di\ContainerInterface;
|
|
|
|
|
2015-10-09 22:29:59 -04:00
|
|
|
/**
|
|
|
|
* View class for outputting HTML
|
|
|
|
*/
|
2015-09-17 23:11:18 -04:00
|
|
|
class HtmlView extends HttpView {
|
|
|
|
|
2015-10-05 16:54:25 -04:00
|
|
|
/**
|
|
|
|
* HTML generator/escaper helper
|
|
|
|
*
|
|
|
|
* @var Aura\Html\HelperLocator
|
|
|
|
*/
|
2015-09-17 23:11:18 -04:00
|
|
|
protected $helper;
|
|
|
|
|
2015-10-05 16:54:25 -04:00
|
|
|
/**
|
|
|
|
* Create the Html View
|
|
|
|
*
|
|
|
|
* @param ContainerInterface $container
|
|
|
|
*/
|
2015-09-17 23:11:18 -04:00
|
|
|
public function __construct(ContainerInterface $container)
|
|
|
|
{
|
|
|
|
parent::__construct($container);
|
2015-10-05 16:54:25 -04:00
|
|
|
$this->helper = $container->get('html-helper');
|
2015-09-17 23:11:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Response mime type
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $contentType = 'text/html';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a basic html Template
|
|
|
|
*
|
|
|
|
* @param string $path
|
|
|
|
* @param array $data
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function render_template($path, $data)
|
|
|
|
{
|
|
|
|
$data['helper'] = $this->helper;
|
|
|
|
$data['escape'] = $this->helper->escape();
|
2015-11-16 19:30:04 -05:00
|
|
|
$data['container'] = $this->container;
|
2015-09-17 23:11:18 -04:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
extract($data);
|
2015-11-11 14:53:09 -05:00
|
|
|
include_once $path;
|
2015-09-17 23:11:18 -04:00
|
|
|
$buffer = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
return $buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// End of HtmlView.php
|