Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/palmtreephp/html
:palm_tree: OOP style HTML elements and selectors
https://github.com/palmtreephp/html
composer-package html html-renderer php
Last synced: about 1 month ago
JSON representation
:palm_tree: OOP style HTML elements and selectors
- Host: GitHub
- URL: https://github.com/palmtreephp/html
- Owner: palmtreephp
- License: mit
- Created: 2016-10-25T11:07:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-07-12T11:41:22.000Z (over 2 years ago)
- Last Synced: 2024-08-08T19:56:42.506Z (5 months ago)
- Topics: composer-package, html, html-renderer, php
- Language: PHP
- Homepage:
- Size: 60.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# :palm_tree: Palmtree Html
[![License](http://img.shields.io/packagist/l/palmtree/form.svg)](LICENSE)
[![Build](https://img.shields.io/github/workflow/status/palmtreephp/html/Build.svg)](https://github.com/palmtreephp/html/actions/workflows/build.yml)Build and render HTML elements using an OOP style interface and jQuery style selectors.
## Requirements
* PHP >= 7.1## Installation
Use composer to add the package to your dependencies:
```bash
composer require palmtree/html
```## Usage Example
```php
'Home',
'href' => 'https://example.org',
];$menuItems[] = [
'label' => 'About',
'href' => 'https://example.org/about',
];$menuItems[] = [
'label' => 'Contact',
'href' => 'https://example.org/contact',
];foreach ($menuItems as $item) {
$a = Element::create('a[href="' . $item['href'] . '"]')->setInnerText($item['label']);$li = Element::create('li.item')->addChild($a);
$li->classes[] = 'item-' . strtolower($item['label']);$menu->addChild($li);
}$menu->attributes->setData('item_total', (string)count($menuItems));
$menu->attributes['aria-label'] = 'Navigation'echo $menu->render();
?>
```Renders the following HTML:
```html
```
## License
Released under the [MIT license](LICENSE)