Clean interface for programmatically creating and manipulating html strings. Useful where desired output depends on various conditions or is otherwise fairly complex, but too brief to justify a template.
This project is still in early development.
Via Composer
composer require webtheory/html
Create one-offs by using the Html static class:
use WebTheory\Html\Html;
use WebTheory\Html\Attributes\ClassList;
$age = 24;
$attributes = [
'id' => $age >= 21 ? 'real-id' : 'fake-id',
'class' => new ClassList(['dummy-class', 'dummy-class-2']),
];
$content = 'This is a test';
echo Html::tag('h1', $content, $attributes);
Or create reusable elements by extending the AbstractHtmlElement class:
Please see CHANGELOG for more information on what has changed recently.
composer test
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.