Download the PHP package dobaniashish/clsx without Composer
On this page you can find all versions of the php package dobaniashish/clsx. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dobaniashish/clsx
More information about dobaniashish/clsx
Files in dobaniashish/clsx
Package clsx
Short Description A utility for constructing html attribute strings conditionally.
License MIT
Homepage https://github.com/dobaniashish/clsx
Informations about the package clsx
clsx for PHP
A PHP utility for constructing html attribute strings conditionally.
[!NOTE] This package is for PHP. If you are looking for JavaScript/React.js, check out the original lukeed/clsx.
This package was inspired from lukeed/clsx to bring similar functionality to PHP with an extra feature to merge all attributes in one function call.
Installation
Usage
This package provides three functions
Clsx::attrs
- Generates full attributes string.Clsx::value
- Generates attribute values string.Clsx::merge
- Merges two attributes array.
Function Clsx::attrs()
Returns generated full attributes string.
Parameters
$attrs_array
(array
) Attributes array.
Usage
Example
Function Clsx::value()
Returns generated attribute value string.
Parameters
$value_array
(array
) Attribute value array.
Usage
Example
Function Clsx::merge()
Returns merged attributes array.
Parameters
$array1
(array
) Attributes value array.$array2
(array
) Attributes value array 2.
Example Usage
Full Usage Example
Outputs
Escaping
Attribute names and values are not escaped automatically. You have to manually escape them.
License
MIT © DobaniAshish