https://src.bluestatic.org
/
hoplite.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2a8d6cd
)
Add functionality to OutputFilter for rendering templates
author
Robert Sesek <rsesek@bluestatic.org>
Mon, 8 Aug 2011 02:19:03 +0000
(22:19 -0400)
committer
Robert Sesek <rsesek@bluestatic.org>
Mon, 8 Aug 2011 02:19:03 +0000
(22:19 -0400)
http/output_filter.php
patch
|
blob
|
history
diff --git
a/http/output_filter.php
b/http/output_filter.php
index 79031ce62ef7d025b3911a51d7a382c7429a014a..5f702ac2dcb3d1cebff6d2050e9186a2f715cc50 100644
(file)
--- a/
http/output_filter.php
+++ b/
http/output_filter.php
@@
-17,6
+17,7
@@
namespace hoplite\http;
require_once HOPLITE_ROOT . '/http/response_code.php';
namespace hoplite\http;
require_once HOPLITE_ROOT . '/http/response_code.php';
+require_once HOPLITE_ROOT . '/views/template_loader.php';
/*!
The OutputFilter is executed after all Actions have been processed. The
/*!
The OutputFilter is executed after all Actions have been processed. The
@@
-34,6
+35,11
@@
class OutputFilter
*/
const RESPONSE_TYPE = 'response_type';
*/
const RESPONSE_TYPE = 'response_type';
+ /*! @const A key in Response#context to render a template with the
+ Response#data when creating a HTML body.
+ */
+ const RENDER_TEMPLATE = 'template';
+
/*!
Constructor that takes a reference to the RootController.
*/
/*!
Constructor that takes a reference to the RootController.
*/
@@
-123,6
+129,10
@@
class OutputFilter
$response->body = $this->_EncodeXML($response->data);
} else if ($type == 'html') {
$response->headers['Content-Type'] = 'text/html';
$response->body = $this->_EncodeXML($response->data);
} else if ($type == 'html') {
$response->headers['Content-Type'] = 'text/html';
+ if (isset($response->context[self::RENDER_TEMPLATE])) {
+ $template = \hoplite\views\TemplateLoader::Fetch($response->context[self::RENDER_TEMPLATE]);
+ $response->body = $template->Render($response->data);
+ }
}
}
}
}