{"id":19398048,"url":"https://github.com/piedweb/renderhtmlattribute","last_synced_at":"2025-07-30T02:06:19.011Z","repository":{"id":57041422,"uuid":"157186877","full_name":"PiedWeb/RenderHtmlAttribute","owner":"PiedWeb","description":"[PHP] Twig Extension to render html attributes","archived":false,"fork":false,"pushed_at":"2025-03-05T10:29:04.000Z","size":33,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T18:20:40.711Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dev.piedweb.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PiedWeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null}},"created_at":"2018-11-12T09:18:34.000Z","updated_at":"2025-02-03T18:06:24.000Z","dependencies_parsed_at":"2023-11-30T19:41:56.615Z","dependency_job_id":null,"html_url":"https://github.com/PiedWeb/RenderHtmlAttribute","commit_stats":{"total_commits":14,"total_committers":4,"mean_commits":3.5,"dds":0.5714285714285714,"last_synced_commit":"ab4f852fd7cb3176ef0f1da2a9f9e10e83fc0bf4"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiedWeb%2FRenderHtmlAttribute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiedWeb%2FRenderHtmlAttribute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiedWeb%2FRenderHtmlAttribute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PiedWeb%2FRenderHtmlAttribute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PiedWeb","download_url":"https://codeload.github.com/PiedWeb/RenderHtmlAttribute/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250572285,"owners_count":21452327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T11:04:45.898Z","updated_at":"2025-04-24T05:31:20.163Z","avatar_url":"https://github.com/PiedWeb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twig Extension : Render html tag attributes\n\n[![Latest Version](https://img.shields.io/github/tag/PiedWeb/RenderHtmlAttribute.svg?style=flat\u0026label=release)](https://github.com/PiedWeb/RenderHtmlAttribute/tags)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)\n[![Code Coverage](https://codecov.io/gh/PiedWeb/PiedWeb/branch/main/graph/badge.svg)](https://codecov.io/gh/PiedWeb/PiedWeb/branch/main)\n[![Type Coverage](https://shepherd.dev/github/PiedWeb/PiedWeb/coverage.svg)](https://shepherd.dev/github/PiedWeb/PiedWeb)\n[![Total Downloads](https://img.shields.io/packagist/dt/piedweb/render-html-attributes.svg?style=flat)](https://packagist.org/packages/piedweb/render-html-attributes)\n\nThis package is an extension for both [Twig](https://github.com/twigphp/Twig) and ~Plate engine [Plates](https://github.com/thephpleague/plates)~.\n\nPlates is not anymore supported since v1.0.3.\n\nTwo features for the same goal **Manipulate html tag attributes via object/PHP array** :\n\n- `attr({class: \"col\", id: \"piedweb\", data-content:\"Hello :)', ...})` transform an array in html tag attributes\n- `mergeAttr($attributes1, $attributes2, [$attributes3, ...])` merge multiple array without loosing values (Eg. : `['class' =\u003e 'main']` + `['class' =\u003e 'content']` = `['class' =\u003e 'main content']`)\n\n## Table of contents\n\n- [Twig Extension : Render html tag attributes](#twig-extension--render-html-tag-attributes)\n  - [Table of contents](#table-of-contents)\n  - [Usage](#usage)\n  - [Installation](#installation)\n  - [Requirements](#requirements)\n  - [Contributors](#contributors)\n  - [License](#license)\n\n## Usage\n\nLoad the extension in twig (eg for symfony) :\n\n```\n        piedweb.twig.extension.render_attributes:\n        class: PiedWeb\\RenderAttributes\\TwigExtension\n        public: false\n        tags:\n            - { name: twig.extension }\n```\n\nThen use it :\n\n```\n{{ attr({class:\"main content\"})|raw }}\n{{ mergeAttr({class:\"main\"}, {class:\"content\"})|raw }}\n```\n\n## Installation\n\n```bash\ncomposer require piedweb/render-html-attributes\n```\n\n## Requirements\n\nStand alone extension.\n\nSee `composer.json` file.\n\n## Contributors\n\n- Original author [Robin (PiedWeb from the Alps Mountain)](https://piedweb.com)\n- ...\n\n## License\n\nMIT (see the LICENSE file for details)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://dev.piedweb.com\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/PiedWeb/piedweb-devoluix-theme/master/src/img/logo_title.png\" width=\"200\" height=\"200\" alt=\"Open Source Package\" /\u003e\n\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiedweb%2Frenderhtmlattribute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiedweb%2Frenderhtmlattribute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiedweb%2Frenderhtmlattribute/lists"}