TurtlePHP Template Plugin parses the buffer and replaces tags that were defined through the PHP-Template library with their respective programmatic response.
It has the PHP-Template library is a requirement. It fails if it hasn't been included.
This library acts primarily as a wrapper. When looking at the
there isn't really much to it. A
Request callback is defined which accepts the
buffer contents as a parameter, and runs it through the
The only other action of this plugin is recording the performance. The
performance (in seconds) is passed as the
Class is instantiable rather than abstract to allow for multiple instances on subrequests.
<?php // template require_once APP . '/vendors/PHP-Template/Template.class.php'; require_once APP . '/vendors/PHP-Template/TemplateTag.class.php'; require_once APP . '/vendors/PHP-Template/HelloWorldTag.class.php'; \Template::addTag('HelloWorld'); // plugin require_once APP . '/vendors/TurtlePHP-TemplatePlugin/Template.class.php'; $request = \Turtle\Application::getRequest(); (new \Plugin\Template($request));
This will simply include the required classes, setup the
HelloWorld tag to be
converted programmatically (through the
HelloWorldTag.class.php file), and
Template plugin (as can be seen through the
Everything else is done automatically. If you want any other custom-tags to be
programatically replaced, check out the PHP-Template library, and remember to
add that tag through the
Sample Templating Performance Header
The following header will be sent along with the response by the framework:
They can easily be viewed by the document through your browser's debug/inspector tool.