ui-awesome/html-attribute
Composer 安装命令:
composer require ui-awesome/html-attribute
包简介
Type-safe traits and backed enums for HTML attribute composition: global attributes, ARIA, data-*, events, and element-specific setters.
关键字:
README 文档
README
Html Attribute
Features
A focused library for building and rendering structured HTML attributes
Type-safe helpers and value objects to compose complex attribute structures (classes, data-attributes, ARIA, etc.).
Installation
composer require ui-awesome/html-attribute:^0.6
Quick start
Compose reusable attribute APIs by combining the package traits with the immutable attribute mixin.
<?php declare(strict_types=1); namespace App; use UIAwesome\Html\Attribute\Global\{HasClass, HasData, HasId}; use UIAwesome\Html\Attribute\HasRel; use UIAwesome\Html\Attribute\Values\Rel; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; final class LinkAttributes { use HasAttributes; use HasClass; use HasData; use HasId; use HasRel; public function render(): string { return Attributes::render($this->getAttributes()); } } $attributes = (new LinkAttributes()) ->id('documentation') ->class('nav-link') ->class('is-active') ->rel(Rel::NOOPENER) ->addDataAttribute('tracking', 'docs'); echo '<a' . $attributes->render() . ' href="/docs">Documentation</a>';
Documentation
For detailed configuration options and advanced usage see:
Package information
Quality code
Our social networks
License
统计信息
- 总下载量: 34.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2024-03-05