{"id":22999048,"url":"https://github.com/ocubom/twig-html-extension","last_synced_at":"2025-04-02T13:42:41.800Z","repository":{"id":139590196,"uuid":"528384716","full_name":"ocubom/twig-html-extension","owner":"ocubom","description":"A custom suite of Twig filters for HTML manipulation","archived":false,"fork":false,"pushed_at":"2023-12-07T08:59:42.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T08:07:54.480Z","etag":null,"topics":["compress","html","minify","twig","twig-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ocubom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-24T11:03:43.000Z","updated_at":"2023-11-08T16:26:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"75385f07-f696-40f1-9193-e5e737dce228","html_url":"https://github.com/ocubom/twig-html-extension","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocubom%2Ftwig-html-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocubom%2Ftwig-html-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocubom%2Ftwig-html-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocubom%2Ftwig-html-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocubom","download_url":"https://codeload.github.com/ocubom/twig-html-extension/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246825850,"owners_count":20840145,"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":["compress","html","minify","twig","twig-extension"],"created_at":"2024-12-15T06:15:24.767Z","updated_at":"2025-04-02T13:42:41.783Z","avatar_url":"https://github.com/ocubom.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\nOcubom Twig HTML Extension\n==========================\n\nA custom suite of Twig filters for HTML manipulation\n\n[![Contributors][contributors-img]][contributors-url]\n[![Forks][forks-img]][forks-url]\n[![Stargazers][stars-img]][stars-url]\n[![Issues][issues-img]][issues-url]\n[![License][license-img]][license-url]\n\n[![Version][packagist-img]][packagist-url]\n[![CI][workflow-ci-img]][workflow-ci-url]\n[![Code Quality][quality-img]][quality-url]\n[![Coverage][coverage-img]][coverage-url]\n\n[**Explore the docs »**](https://github.com/ocubom/twig-html-extension)\n\n[Report Bug](https://github.com/ocubom/twig-html-extension/issues)\n·\n[Request Feature](https://github.com/ocubom/twig-html-extension/issues)\n\n\u003c/div\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eContents\u003c/summary\u003e\n\n* [About TwigHtmlExtension](#about-twightmlextension)\n* [Getting Started](#getting-started)\n    * [Installation](#installation)\n    * [Usage](#usage)\n* [Roadmap](#roadmap)\n* [Contributing](#contributing)\n* [Authorship](#authorship)\n* [License](#license)\n\n\u003c/details\u003e\n\n## About TwigHtmlExtension\n\n[TwigHtmlExtension](https://github.com/ocubom/twig-html-extension) is a custom suite of **[Twig filters]** for HTML manipulation.\n\nThis suite started as an internal class based on [nochso/html-compress-twig][] to allow the use of [wyrihaximus/html-compress][] with Twig 3.0.\nThis class used to be embedded into several projects.\nOver time, each project adapted its version slightly, leading to fragmented development and difficult maintenance.\nTherefore, the development is unified in this extension which is made public in case it is useful for other projects.\n\n## Getting Started\n\n### Installation\n\nJust use [composer][] to add the dependency:\n\n```console\ncomposer require ocubom/twig-html-extension\n```\n\nOr add the dependency manually:\n\n1.  Update ``composer.json`` file with the lines:\n\n    ```json\n    {\n        \"require\": {\n            \"ocubom/twig-html-extension\": \"^1.0.0\"\n        }\n    }\n    ```\n\n2.  And update the dependencies:\n\n    ```console\n    composer update \"ocubom/twig-html-extension\"\n    ```\n\n### Usage\n\nJust register the Twig extension:\n\n```php\n$twig = new \\Twig\\Environment();\n$twig-\u003eaddExtension(new \\Ocubom\\Twig\\Extension\\HtmlExtension());\n$thig-\u003eaddRuntimeLoader(use Twig\\RuntimeLoader\\FactoryRuntimeLoader([\n    \\Ocubom\\Twig\\Extension\\HtmlAttributesRuntime::class =\u003e function() {\n        return new \\Ocubom\\Twig\\Extension\\HtmlAttributesRuntime();\n    },\n    \\Ocubom\\Twig\\Extension\\HtmlCompressRuntime::class =\u003e function() {\n        return new \\Ocubom\\Twig\\Extension\\HtmlCompressRuntime();\n    },\n]));\n\n// You can also dynamically create a RuntimeLoader \n$twig-\u003eaddRuntimeLoader(new class() implements RuntimeLoaderInterface {\n    public function load($class)\n    {\n        if (\\Ocubom\\Twig\\Extension\\HtmlAttributesRuntime::class === $class) {\n            return new \\Ocubom\\Twig\\Extension\\HtmlAttributesRuntime();\n        }\n        \n        if (\\Ocubom\\Twig\\Extension\\HtmlCompressRuntime::class === $class) {\n            return new \\Ocubom\\Twig\\Extension\\HtmlCompressRuntime();\n        }\n        \n        return null;\n    }\n});\n```\n\n_For more examples, please refer to the [Documentation](https://github.com/ocubom/twig-html-extension)._\n\n## Roadmap\n\nSee the [open issues](https://github.com/ocubom/twig-html-extension/issues) for a full list of proposed features (and known issues).\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create.\nAny contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request.\nYou can also simply open an issue with the tag \"enhancement\".\n\n1. Fork the Project.\n2. Create your Feature Branch (`git checkout -b feature/your-feature`).\n3. Commit your Changes (`git commit -m 'Add your-feature'`).\n4. Push to the Branch (`git push origin feature/your-feature`).\n5. Open a Pull Request.\n\n## Authorship\n\n* Oscar Cubo Medina — https://ocubom.github.io\n\nSee also the list of [contributors][contributors-url] who participated in this project.\n\n## License\n\nDistributed under the MIT License.\nSee [LICENSE][] for more information.\n\n\n[LICENSE]: https://github.com/ocubom/twig-html-extension/blob/master/LICENSE\n\n\u003c!-- Links --\u003e\n[composer]: https://getcomposer.org/\n[Symfony]: https://symfony.com/\n[Twig filters]: https://twig.symfony.com/doc/3.x/advanced.html#filters\n\n\u003c!-- Packagist links --\u003e\n[nochso/html-compress-twig]: https://packagist.org/packages/nochso/html-compress-twig\n[wyrihaximus/html-compress]: https://packagist.org/packages/wyrihaximus/html-compress\n\n\u003c!-- Project Badges --\u003e\n[contributors-img]: https://img.shields.io/github/contributors/ocubom/twig-html-extension.svg?style=for-the-badge\n[contributors-url]: https://github.com/ocubom/twig-html-extension/graphs/contributors\n[forks-img]:        https://img.shields.io/github/forks/ocubom/twig-html-extension.svg?style=for-the-badge\n[forks-url]:        https://github.com/ocubom/twig-html-extension/network/members\n[stars-img]:        https://img.shields.io/github/stars/ocubom/twig-html-extension.svg?style=for-the-badge\n[stars-url]:        https://github.com/ocubom/twig-html-extension/stargazers\n[issues-img]:       https://img.shields.io/github/issues/ocubom/twig-html-extension.svg?style=for-the-badge\n[issues-url]:       https://github.com/ocubom/twig-html-extension/issues\n[license-img]:      https://img.shields.io/github/license/ocubom/twig-html-extension.svg?style=for-the-badge\n[license-url]:      https://github.com/ocubom/twig-html-extension/blob/master/LICENSE\n[workflow-ci-img]:  https://img.shields.io/github/actions/workflow/status/ocubom/twig-html-extension/ci.yml?branch=main\u0026label=CI\u0026logo=github\u0026style=for-the-badge\n[workflow-ci-url]:  https://github.com/ocubom/twig-html-extension/actions/\n[packagist-img]:    https://img.shields.io/packagist/v/ocubom/twig-html-extension.svg?logo=packagist\u0026logoColor=%23fefefe\u0026style=for-the-badge\n[packagist-url]:    https://packagist.org/packages/ocubom/twig-html-extension\n[coverage-img]:     https://img.shields.io/scrutinizer/coverage/g/ocubom/twig-html-extension.svg?logo=scrutinizer\u0026logoColor=fff\u0026style=for-the-badge\n[coverage-url]:     https://scrutinizer-ci.com/g/ocubom/twig-html-extension/code-structure/main/code-coverage\n[quality-img]:      https://img.shields.io/scrutinizer/quality/g/ocubom/twig-html-extension.svg?logo=scrutinizer\u0026logoColor=fff\u0026style=for-the-badge\n[quality-url]:      https://scrutinizer-ci.com/g/ocubom/twig-html-extension/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focubom%2Ftwig-html-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focubom%2Ftwig-html-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focubom%2Ftwig-html-extension/lists"}