PHPackages                             piedweb/render-html-attributes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. piedweb/render-html-attributes

ActiveLibrary[Templating &amp; Views](/categories/templating)

piedweb/render-html-attributes
==============================

\[Twig Extension\] Transform an array in html tag attributes.

0.1.890(2mo ago)547.3k↓11.3%1[1 issues](https://github.com/PiedWeb/RenderHtmlAttribute/issues)2MITPHPPHP &gt;=8.4CI failing

Since Dec 4Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/PiedWeb/RenderHtmlAttribute)[ Packagist](https://packagist.org/packages/piedweb/render-html-attributes)[ Docs](https://piedweb.com)[ RSS](/packages/piedweb-render-html-attributes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (12)Used By (2)

Twig Extension : Render html tag attributes
===========================================

[](#twig-extension--render-html-tag-attributes)

[![Latest Version](https://camo.githubusercontent.com/d53b8936ca3a3be35a14c89be87ce211d9bff17003793fbb825e00208a1be142/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f506965645765622f52656e64657248746d6c4174747269627574652e7376673f7374796c653d666c6174266c6162656c3d72656c65617365)](https://github.com/PiedWeb/RenderHtmlAttribute/tags)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE)[![Code Coverage](https://camo.githubusercontent.com/ad1c5df148038d50b23b6d13436b75553ac9e6d133450cf73859c7bec532334b/68747470733a2f2f636f6465636f762e696f2f67682f506965645765622f506965645765622f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/PiedWeb/PiedWeb/branch/main)[![Type Coverage](https://camo.githubusercontent.com/92a9cae37a1391395968437e74aca983df381125f0db54069dbe9d52f4a5d483/68747470733a2f2f73686570686572642e6465762f6769746875622f506965645765622f506965645765622f636f7665726167652e737667)](https://shepherd.dev/github/PiedWeb/PiedWeb)[![Total Downloads](https://camo.githubusercontent.com/cb52fda544807d6bf35e4b8576d1f44de3ea91cc3505237ff7392323ac02b593/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706965647765622f72656e6465722d68746d6c2d617474726962757465732e7376673f7374796c653d666c6174)](https://packagist.org/packages/piedweb/render-html-attributes)

This package is an extension for both [Twig](https://github.com/twigphp/Twig) and Plate engine [Plates](https://github.com/thephpleague/plates).

Plates is not anymore supported since v1.0.3.

Two features for the same goal **Manipulate html tag attributes via object/PHP array** :

- `attr({class: "col", id: "piedweb", data-content:"Hello :)', ...})` transform an array in html tag attributes
- `mergeAttr($attributes1, $attributes2, [$attributes3, ...])` merge multiple array without loosing values (Eg. : `['class' => 'main']` + `['class' => 'content']` = `['class' => 'main content']`)

Table of contents
-----------------

[](#table-of-contents)

- [Twig Extension : Render html tag attributes](#twig-extension--render-html-tag-attributes)
    - [Table of contents](#table-of-contents)
    - [Usage](#usage)
    - [Installation](#installation)
    - [Requirements](#requirements)
    - [Contributors](#contributors)
    - [License](#license)

Usage
-----

[](#usage)

Load the extension in twig (eg for symfony) :

```
        piedweb.twig.extension.render_attributes:
        class: PiedWeb\RenderAttributes\TwigExtension
        public: false
        tags:
            - { name: twig.extension }

```

Then use it :

```
{{ attr({class:"main content"})|raw }}
{{ mergeAttr({class:"main"}, {class:"content"})|raw }}

```

Installation
------------

[](#installation)

```
composer require piedweb/render-html-attributes
```

Requirements
------------

[](#requirements)

Stand alone extension.

See `composer.json` file.

Contributors
------------

[](#contributors)

- Original author [Robin (PiedWeb from the Alps Mountain)](https://piedweb.com)
- ...

License
-------

[](#license)

MIT (see the LICENSE file for details)

[![Open Source Package](https://raw.githubusercontent.com/PiedWeb/piedweb-devoluix-theme/master/src/img/logo_title.png)](https://dev.piedweb.com)

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance84

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~98 days

Total

10

Last Release

78d ago

PHP version history (2 changes)0.1.836PHP ^8.1

0.1.890PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/afce4cf517928a50560237f1410d5957271fd808671b2216687ecf1422adaee0?d=identicon)[Robin D.](/maintainers/Robin%20D.)

---

Top Contributors

[![RobinDev](https://avatars.githubusercontent.com/u/3944894?v=4)](https://github.com/RobinDev "RobinDev (11 commits)")[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (3 commits)")[![nlemoine](https://avatars.githubusercontent.com/u/2526939?v=4)](https://github.com/nlemoine "nlemoine (1 commits)")

---

Tags

twightmltemplatetemplatingattributesviewplates

### Embed Badge

![Health badge](/badges/piedweb-render-html-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/piedweb-render-html-attributes/health.svg)](https://phpackages.com/packages/piedweb-render-html-attributes)
```

###  Alternatives

[latte/latte

☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites. Introduces context-sensitive escaping.

1.3k15.7M683](/packages/latte-latte)[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8208.4M87](/packages/eftec-bladeone)[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7526.3M230](/packages/laminas-laminas-view)[wyrihaximus/twig-view

Twig powered View for CakePHP

804.7M1](/packages/wyrihaximus-twig-view)[eftec/bladeonehtml

The standalone version Blade Template Engine from Laravel in a single php file

1018.1k5](/packages/eftec-bladeonehtml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
