ui-awesome/html-core

UI Awesome HTML Core Code Generator for PHP.

0.1.0 2024-03-30 20:03 UTC

This package is auto-updated.

Last update: 2024-11-30 21:26:37 UTC


README

UI Awesome HTML Core Code Generator for PHP.


PHPUnit Codecov Infection Psalm Psalm Coverage Style ci

This package provides a set of HTML helper and widgets for generating HTML elements in a programmatic way with PHP.

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist ui-awesome/html-core:^0.1

or add

"ui-awesome/html-core": "^0.1"

to the require section of your composer.json file.

Usage

Create a new HTML element

To create a new HTML element, you can use the HTMLBuilder::class with the createTag() method.

Allowed arguments are:

  • tag (string) - The tag name.
  • content (string) - The content of the tag.
  • attributes (array) - The attributes of the tag.
<?php

declare(strict_types=1);

use UIAwesome\Html\Core\HTMLBuilder;
?>

<?= HTMLBuilder::createTag('div', 'Hello, World!', ['class' => 'container']) ?>

Create a new HTML block element

To create a new HTML block element, you can use the HTMLBuilder::class with the beginTag() and endTag() methods.

Allowed arguments for beginTag() method are:

  • tag (string) - The tag name.
  • attributes (array) - The attributes of the tag.

Allowed arguments for endTag() method are:

  • tag (string) - The tag name.
<?php

declare(strict_types=1);

use UIAwesome\Html\Core\HTMLBuilder;

<?= HTMLBuilder::beginTag('div', ['class' => 'container']) ?>
    Hello, World!
<?= HTMLBuilder::endTag('div') ?>

Generic widget

Testing

Check the documentation testing to learn about testing.

Support versions

PHP81

License

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

Our social networks

Twitter