Download the PHP package lordsimal/custom-html-elements without Composer
On this page you can find all versions of the php package lordsimal/custom-html-elements. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lordsimal/custom-html-elements
More information about lordsimal/custom-html-elements
Files in lordsimal/custom-html-elements
Package custom-html-elements
Short Description Allows you to create custom HTML elements to render more complex template parts
License MIT
Informations about the package custom-html-elements
Custom HTML Elements
Allows you to create custom HTML elements to render more complex template parts with a simpler HTML representation
Requirements
- PHP 8.1+
Installation
Usage
This is an example representation of a custom HTML element you want to use:
So this would appear in a HTML output like this:
To render this custom HTML element you need to do this:
The element logic can be placed in e.g. Tags/Youtube.php
or OtherTagsFolder/Youtube.php
:
As you can see the main 2 parts are the
which defines what HTML tag is represented by this class and the render()
method.
Inside the render()
method you have access to all HTML attributes which you pass onto your element.
So e.g.
would be accessible inside the Button
class via
Accessing the inner content
You may want to create custom HTML elements like
To access the Inner Content
text inside your class you simply have to call $this->innerContent
like so
Self closing elements
By default every custom HTML element can be used either way:
or
both are rendered the same way.
Rendering nested custom HTML elements
By default, this library renders nested custom HTML elements. So you don't need to worry about that.
Disabling custom HTML elements
You have 2 ways how you can disable custom HTML elements:
Disable all occurence of custom HTML elements
You can add the attributes
to your Custom HTML Element class.
Disable only specific occurence of custom HTML elements
You can add the attribute disabled
, then it will not be rendered.
More examples?
See all the different TagEngine Tests
Acknowledgements
This library is inspired by the following packages