Create html strings from structured data

0.3.1 2022-05-23 23:44 UTC

This package is auto-updated.

Last update: 2024-10-27 01:08:51 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

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.

Install

Via Composer

composer require webtheory/html

Usage

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:


Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email spider.mane.web@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.