Home

Awesome

<p align="center"> <code lang="html">&lt;PHPX templates /&gt;</code><br><br> PHPX Templates is a template engine built around <a href="https://github.com/buttress/phpx">PHPX</a> and <a href="https://github.com/buttress/phpx-compile">PHPX Compile</a> </p>

Theme

<?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.')))
        ])
    ])
]);

Page

<?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'));

Installation

To install PHPX, use composer:

composer require buttress/templates

Usage

See the example for basic usage

Related Projects

Contributing

Contributions to PHPX Templates are always welcome! Feel free to fork the repository and submit a pull request.

License

PHPX Templates is released under the MIT License.

Githooks

To add our githooks and run tests before commit:

git config --local core.hooksPath .githooks

Support

If you encounter any problems or have any questions, please open an issue on GitHub.

Thanks for checking out PHPX Templates ❤️