The packages provides an HTML5 mini template for quick rendering of status pages, TOC pages, or any other minimal single-serving site.
This package provides a single class to turn a text or HTML-snippet into a valid HTML5 document.
This way it is possible to let an app return an HTML response without the need to store a template file beforehand or initialize a full-blown template engine.
The package therefore does not have template variables, modifiers or parsers. Three lines of code should be sufficient to wrap a given message into a valid HTML document. See »Usage« for some examples.
The package follows the KISS principle.
- PHP
Packagist Entry https://packagist.org/packages/pixelbrackets/html5-mini-template/
https://gitlab.com/pixelbrackets/html5-mini-template/
-
Get the example template
$document = (new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate())->getMarkup();
-
Get template with custom content and write to file
$template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate(); $template->setContent('<h1>Index</h1><p>Nothing to see here</p>'); file_put_contents('/var/www/example/index.html', $template->getMarkup());
-
Get template with custom content, an external link to a CSS framework output the document as response
$template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate(); $template->setStylesheet('skeleton'); $template->setContent('<h1>Status</h1><p>All Systems Operational</p>'); echo $template->getMarkup();
setContent()the message to show, any HTML string to replace the main content of the documentsetStylesheet()may be a URL to any existing stylesheet or one of following reserved keywords which then creates a link to a CDN of the selected CSS frameworksetStylesheetMode()either link the given stylesheet (Html5MiniTemplate::STYLE_LINK, default) or fetch its content and print it inline (Html5MiniTemplate::STYLE_INLINE).setTitle()the title is the first headline found in the document, unless it is overwritten with this option
GNU General Public License version 2 or later
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html.
Dan Untenzu ([email protected] / @pixelbrackets)
See ./CHANGELOG.md
This script is Open Source, so please use, patch, extend or fork it.
Contributions are welcome!