pressmodo / wp-attributes
An helper library to generate attributes for HTML elements.
1.0.0
2020-06-22 10:23 UTC
Requires
- php: >=5.6
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.5.0
- php-mock/php-mock-phpunit: ^2.5
- phpunit/phpunit: ^6.5.5
- pressmodo/phpcs-config: dev-master
This package is auto-updated.
Last update: 2024-12-22 20:28:53 UTC
README
An helper library to generate attributes for HTML elements.
Installation
composer require pressmodo/wp-attributes
Basic usage
use Pressmodo\Attributes\AttributesInterface; $sut = new AttributesInterface(); $sut->add( 'context', [ 'class' => 'color-primary', 'id' => 'unique_id', ] ); // ' class="color-primary" id="unique_id"' echo $sut->render( 'context' ); $sut->add( 'another_context', [ 'class' => '', // This will be skipped because empty 'attr1' => null, // This will be skipped because null 'attr2' => false, // This will be skipped because false 'attr3' => 0, // This will be skipped because 0 is also false 'id' => 'unique_id', ] ); // ' id="unique_id"' echo $sut->render( 'another_context' );