Download the PHP package patrickschur/html5gen without Composer
On this page you can find all versions of the php package patrickschur/html5gen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download patrickschur/html5gen
More information about patrickschur/html5gen
Files in patrickschur/html5gen
Package html5gen
Short Description An easy to use HTML5 generator written in PHP. Creates valid and secure HTML5 code.
License MIT
Homepage https://github.com/patrickschur/html5gen
Informations about the package html5gen
html5gen
An easy to use HTML5 generator written in PHP. Creates valid and secure HTML5 code.
Installation
To install the library I would recommend to use Composer. Execute the following command
or add this to your composer.json
Because the script is not really big you could also copy the Html5Gen.php
out of the src
folder to use the script without Composer.
Usage
outputs:
Attributes
All elements have one thing in common, all of them expect attributes. That is also the reason why it is the first parameter of all methods. You can specify attributes by an array. Where the key is the name of the attribute and the value the attribute value. If you do not want to specify attributes, leave the array empty. You can also omit the array if you do not use a callback.
outputs:
Callbacks
The second and last parameter is the a callback function defined by the user.
This lets you write a more generic code and allows the nesting of elements.
With the yield
keyword it is possible to write text into the current element without terminating the function.
Notice: Elements like
base
,br
,meta
,area
,input
,wbr
,hr
,link
,param
,source
,col
andimg
can not have a callback, only attributes.
outputs:
Automatically Escaped Values
The script will automatically detect if it is useful to escape a value or not.
For example if you want to define a script
tag, it would not be useful to escape, because that destroys the logic of a script.
But if you use a pre
tag it makes much more sense to escape the value. Also works for attributes.
outputs:
[TODO] Checklist:
- [x] Exists the attribute for the element? (Find a better implementation of that!)
- [ ] Is the given attribute value allowed for the specified attribute?
- [ ] Is the element allowed in the current element?
- [ ] Check the document for bad practices. For example duplicate id references.
- [ ] Check the
nonce
andintegrity
attribute on the correctness.
Contributing
Feel free to contribute. Any help is welcome.
License
This projects is licensed under the terms of the MIT license.