https://github.com/pixelbrackets/html5-mini-template
HTML5 Mini Template for quick rendering of status pages, TOC pages, or any other minimal single-serving site
https://github.com/pixelbrackets/html5-mini-template
html5 microservice minimal php stylesheet template
Last synced: 3 months ago
JSON representation
HTML5 Mini Template for quick rendering of status pages, TOC pages, or any other minimal single-serving site
- Host: GitHub
- URL: https://github.com/pixelbrackets/html5-mini-template
- Owner: pixelbrackets
- Created: 2019-08-05T12:12:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T11:16:00.000Z (over 3 years ago)
- Last Synced: 2025-03-06T18:29:38.204Z (about 1 year ago)
- Topics: html5, microservice, minimal, php, stylesheet, template
- Language: PHP
- Homepage: https://gitlab.com/pixelbrackets/html5-mini-template/
- Size: 119 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# HTML5 Mini Template
[](https://packagist.org/packages/pixelbrackets/html5-mini-template/)
[](https://gitlab.com/pixelbrackets/html5-mini-template/pipelines)
[](https://gitlab.com/pixelbrackets/html5-mini-template#requirements)
[](https://spdx.org/licenses/GPL-2.0-or-later.html)
[](https://gitlab.com/pixelbrackets/html5-mini-template/-/blob/master/CONTRIBUTING.md)
HTML5 Mini Template for quick rendering of status pages, TOC pages,
or any other minimal single-serving site.

_⭐ You like this package? Please star it or send a tweet. ⭐_
## Vision
This package provides a single class to turn a message 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 or modifiers.
Two lines of code should be sufficient to wrap a given text into a valid
HTML document. One more to add a link to fancy stylesheet.
See [»Usage«](#usage) for some examples.
The package follows the KISS principle.
## Webapp
This package is used on [html5example.com](https://html5example.com/).
If you are in need of a boilerplate HTML document once only, then you may use a
commandline tool like cURL or HTTPie and run
`http https://html5example.com > index.html` to save a template file.
The webapp supports some [options](#options) of this package as well,
for example
`http POST https://html5example.com title=Minimal-Template > index.html`
to pass a custom title.
## Requirements
- PHP
## Installation
Packagist Entry https://packagist.org/packages/pixelbrackets/html5-mini-template/
## Source
https://gitlab.com/pixelbrackets/html5-mini-template/
Mirror https://github.com/pixelbrackets/html5-mini-template/ (Issues & Pull Requests
mirrored to GitLab)
## Demo
⌨️ [`php tests/demo.php`](./tests/demo.php).
## Usage
1. Wrap a message into a HTML5 document, return to a PSR-7 implementation
```php
$template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate();
$template->setContent('
Status
All Systems Operational
');
return $template->getMarkup();
```
1. Wrap a message, use a preconfigured CSS framework CDN
(see [»options«](#options) for a list of supported frameworks),
and save the document into a file
```php
$template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate();
$template->setStylesheet('barbone');
$template->setContent('
Index
Nothing to see here
');
file_put_contents('/var/www/example/index.html', $template->getMarkup());
```
1. Wrap a message, set your own stylesheet URL, set a title,
output the document
```php
$template = (new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate())
->setStylesheet('/assets/styles.css')
->setTitle('Index')
->setContent('
TOC
- a
- b
echo $template->getMarkup();
```
1. Get the boilerplate example template only (👉 or use the [Webapp](#webapp))
```php
echo \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate::getTemplate();
```
### Options
- `setContent()` (*string*) the message to show, any HTML string to set
the main content of the document – if empty, then a
[boilerplate](https://html5example.com/) example content is used instead
- 💭 You work with Markdown content? Use the drop-in replacement package
[pixelbrackets/markdown-mini-page](https://packagist.org/packages/pixelbrackets/markdown-mini-page/)
to convert Markdown into HTML straightaway
- `setStylesheet()` (*string*) may be a URL to any existing stylesheet *or*
one of following reserved keywords – each keyword creates a link to a CDN
of the associated CSS framework
- `barebone` ([Barebone Stylesheet](https://github.com/pixelbrackets/barebone-stylesheet/)) – *super lightweight*
- `bootstrap` ([Bootstrap](https://github.com/twbs/bootstrap/))
- `gfm` ([GitHub Flavored Markdown Stylesheet](https://github.com/pixelbrackets/gfm-stylesheet/))
- `milligram` ([Milligram](https://github.com/milligram/milligram/))
- `minicss` ([mini.css](https://github.com/Chalarangelo/mini.css/))
- `mui` ([MUI - Material Design CSS Framework](https://github.com/muicss/mui/))
- `mvp` ([MVP.css](https://github.com/andybrewer/mvp/))
- `picnic` ([Picnic CSS](https://github.com/franciscop/picnic/))
- `skeleton` ([Skeleton](https://github.com/dhg/Skeleton/))
- `setStylesheetMode()` (*string*) switch between a link to the given stylesheet
(using the constant `Html5MiniTemplate::STYLE_LINK`, this is the default mode)
or fetch the stylesheet file content and print it inline
(using the constant `Html5MiniTemplate::STYLE_INLINE`)
- `setTitle()` (*string*) the document title – if empty, then the first H1
headline found in the main content is used as title instead
- `setAdditionalMetadata()` (*string*) any additional metadata like metatags,
custom styles or link references like a canonical link
- ⚠️ Usage of this option is an indicator that the given use case is too
specific and switching to a template engine like the minimal
[slim/php-view](https://packagist.org/packages/slim/php-view) or the
powerfull [twig/twig](https://packagist.org/packages/twig/twig)
should be considered
## License
GNU General Public License version 2 or later
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html.
## Author
Dan Untenzu ( / [@pixelbrackets](https://pixelbrackets.de))
## Changelog
See [CHANGELOG.md](./CHANGELOG.md)
## Contribution
This script is Open Source, so please use, share, patch, extend or fork it.
[Contributions](./CONTRIBUTING.md) are welcome!
## Feedback
Please send some [feedback](https://pixelbrackets.de/) and share how this
package has proven useful to you or how you may help to improve it.