<PHPX templates />
PHPX Templates is a template engine built around PHPX and PHPX Compile
<?php
assert($options instanceof \Buttress\PhpxTemplates\ThemeOptions);
$x = $options->x;
return $x->html(c: [
$x->head(c: [
$x->title(c: $options->block('head-title', 'My default site title')),
$x->raw($options->block('head-extra')),
]),
$x->body(c: [
$x->header(c: $x->h1($options->block('title', 'My Site')),
$x->main(c: [
$x->raw($options->block('content', fn() => $x->div('No content provided.')))
])
])
]);
<?php
// Change this to match what your template expects
assert($options instanceof \Buttress\PhpxTemplates\TemplateOptions);
$x = $options->x;
return \Phpx\Templates\ThemedResult::create('my/theme')
->withBlock('title', 'My custom page title')
->withBlock('content', $x->div('Here\'s the content'));
To install PHPX, use composer:
composer require buttress/templates
See the example for basic usage
- PHPX A fluent DOMDocument wrapper that makes it easy to write safe valid HTML in plain PHP.
- PHPX Compile An experimental compiler for PHPX. Significantly reduces function calls.
Contributions to PHPX Templates are always welcome! Feel free to fork the repository and submit a pull request.
PHPX Templates is released under the MIT License.
To add our githooks and run tests before commit:
git config --local core.hooksPath .githooks
If you encounter any problems or have any questions, please open an issue on GitHub.
Thanks for checking out PHPX Templates ❤️