Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hexmakina/marker
HTML Generation classes
https://github.com/hexmakina/marker
html php php7
Last synced: 2 months ago
JSON representation
HTML Generation classes
- Host: GitHub
- URL: https://github.com/hexmakina/marker
- Owner: HexMakina
- License: mit
- Created: 2021-08-08T00:28:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-18T18:49:39.000Z (8 months ago)
- Last Synced: 2024-10-14T03:42:19.527Z (3 months ago)
- Topics: html, php, php7
- Language: PHP
- Homepage:
- Size: 86.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/HexMakina/Marker/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/HexMakina/Marker/?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/b2b950b6a92899acc876/maintainability)](https://codeclimate.com/github/HexMakina/Marker/maintainability)
[![Latest Stable Version](http://poser.pugx.org/hexmakina/marker/v)](https://packagist.org/packages/hexmakina/marker)
[![License](http://poser.pugx.org/hexmakina/marker/license)](https://packagist.org/packages/hexmakina/marker)# Marker
HTML Generation classes
Hommage to Christian François Bouche-Villeneuve aka Chris Marker# Class Element
The Element class provides a simple and useful implementation for creating, and generating valid HTML elements using PHP
The __toString() method of the Element class generates the HTML code for the element based on its tag, attributes, and contentAdditionally, the Element class provides a static shorthand syntax, using __callStatic() matching the name of the HTML Element to create
The first argument is the content, the second are the attributes
$abbr = Element::abbr('RTFM', ['title' => 'read the file manual']);
$p = Element:p('You reading this means you know about '.$abbr);
echo $p; //You reading this means you know about RTFM
::span('inner text', ['class' => 'd-block'])
::p('lorem ipsum')
::img(null, ['src' => 'path/to/jpeg.png', alt='hyper descriptive', 'width' => 100, 'height'=>100])
::a('click here', ['href' => 'url/to/destination', 'class' => 'nav-link'])
::a('anchor title', ['name' => 'anchor_name'])Regarding the attributes array, the keys represent the attribute names, and the values represent the attribute values.
If an attribute key is an integer, the corresponding attribute name and value are treated as a boolean attribute.Example usage:
```
$element = new Element('section', 'Hello World!', [
'id' => 'publication',
'class' => 'container',
'data-toggle' => 'modal',
'data-target' => '#myModal',
]);Hello World!
```Or, with void element and boolean attributes:
$element = new Element('input', null, [
'type' => 'checkbox',
'checked',
'disabled',
'class' => 'checkbutton'
]);# Class Marker
# Class Form