{"id":13549046,"url":"https://github.com/decodelabs/tagged","last_synced_at":"2025-04-15T14:07:37.577Z","repository":{"id":53717563,"uuid":"207402228","full_name":"decodelabs/tagged","owner":"decodelabs","description":"PHP markup generation without the fuss","archived":false,"fork":false,"pushed_at":"2025-04-14T08:49:58.000Z","size":408,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-14T09:46:33.084Z","etag":null,"topics":["html","markup","php","tags"],"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/decodelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-09-09T20:50:42.000Z","updated_at":"2025-04-14T08:50:02.000Z","dependencies_parsed_at":"2023-02-15T07:46:34.673Z","dependency_job_id":"4eb52026-6f9f-46e4-8fa1-b9fefa83a2c4","html_url":"https://github.com/decodelabs/tagged","commit_stats":{"total_commits":319,"total_committers":2,"mean_commits":159.5,"dds":"0.0031347962382445305","last_synced_commit":"50023ac1fa13d086a251e4b313b9d287a47154fd"},"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ftagged","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ftagged/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ftagged/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Ftagged/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decodelabs","download_url":"https://codeload.github.com/decodelabs/tagged/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860144,"owners_count":21173339,"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":["html","markup","php","tags"],"created_at":"2024-08-01T12:01:17.634Z","updated_at":"2025-04-15T14:07:37.567Z","avatar_url":"https://github.com/decodelabs.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Tagged\n\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/tagged?style=flat)](https://packagist.org/packages/decodelabs/tagged)\n[![Latest Version](https://img.shields.io/packagist/v/decodelabs/tagged.svg?style=flat)](https://packagist.org/packages/decodelabs/tagged)\n[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/tagged.svg?style=flat)](https://packagist.org/packages/decodelabs/tagged)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/tagged/integrate.yml?branch=develop)](https://github.com/decodelabs/tagged/actions/workflows/integrate.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true\u0026style=flat)](https://github.com/phpstan/phpstan)\n[![License](https://img.shields.io/packagist/l/decodelabs/tagged?style=flat)](https://packagist.org/packages/decodelabs/tagged)\n\n### PHP markup generation without the fuss.\n\nTagged provides a simple, powerful and beautiful way to create HTML markup without the spaghetti.\n\n---\n\n\n## Installation\n\n```bash\ncomposer require decodelabs/tagged\n```\n\n## Usage\n\nTagged uses [Veneer](https://github.com/decodelabs/veneer) to provide a unified frontage under \u003ccode\u003eDecodeLabs\\Tagged\u003c/code\u003e.\nYou can access all the primary HTML functionality via this static frontage without compromising testing and dependency injection.\n\n\n## HTML markup\n\nGenerate markup using a simple, flexible interface.\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\necho Html::{'div.my-class#my-id'}('This is element content', [\n    'title' =\u003e 'This is a title'\n]);\n```\n\n...creates:\n\n```html\n\u003cdiv class=\"my-class\" id=\"my-id\" title=\"This is a title\"\u003eThis is element content\u003c/div\u003e\n```\n\nCreate individual tags without content:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\n$tag = Html::tag('div.my-class');\n\necho $tag-\u003eopen();\necho 'Content';\necho $tag-\u003eclose();\n```\n\nWrap HTML strings to be used where an instance of \u003ccode\u003eMarkup\u003c/code\u003e is needed:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\n$buffer = Html::raw('\u003cspan class=\"test\"\u003eMy span\u003c/span\u003e');\n```\n\nDump script data to Html:\n\n```php\nyield Html::script(Html::raw(json_encode( $some_data )), [\n    'type' =\u003e 'application/json'\n]);\n```\n\nPrepare arbitrary input for Markup output:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\n$markup = Html::wrap(\n    function() {\n        yield Html::h1('My title');\n    },\n    [Html::p(['This is ', Html::strong('mixed'), ' content'])]\n);\n```\n\n### Attributes\n\nSet attributes inline:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\necho Html::{'div[data-attr=foo]'}('This is a div with an attribute');\n```\n\nSet attributes via an array:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\necho Html::{'div'}('This is a div with an attribute', [\n    'data-attr' =\u003e 'foo'\n]);\n```\n\nSet attributes with named arguments:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\necho Html::{'div'}(\n    'This is a div with an attribute',\n    dataAttr: 'foo',\n    class: 'my-class'\n);\n```\n\n\n### Nesting\n\nYou can nest elements in multiple ways:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\n// Pass in nested elements via array\necho Html::div([\n    Html::{'span.inner1'}('Inner 1'),\n    ' ',\n    Html::{'span.inner2'}('Inner 2')\n]);\n\n\n// Return anything and everything via a generator\necho Html::div(function($el) {\n    // $el is the root element\n    $el-\u003eaddClass('container');\n\n    // Nest elements with a single call\n    yield Html::{'header \u003e h1'}('This is a header');\n    yield Html::p('This is a paragraph');\n\n    // Set attributes inline\n    yield Html::{'p[data-target=open]'}('Target paragraph');\n\n    // Generator return values are rendered too\n    return Html::{'div.awesome'}('This is awesome!');\n});\n```\n\n\n### Time and date\nFormat and wrap dates and intervals\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\n// Custom format\nHtml::$time-\u003eformat('now', 'd/m/Y', 'Europe/London');\n\n// Locale format\n// When timezone is true it is fetched from Cosmos::$timezone\nHtml::$time-\u003elocale('now', 'long', 'long', true);\n\n// Locale shortcuts\nHtml::$time-\u003edateTime('tomorrow'); // medium\nHtml::$time-\u003elongTime('yesterday');\nHtml::$time-\u003eshortDate('yesterday');\n// ...etc\n\n\n// Intervals\nHtml::$time-\u003esince('yesterday'); // 1 day ago\nHtml::$time-\u003euntil('tomorrow'); // 1 day from now\nHtml::$time-\u003esinceAbs('yesterday'); // 1 day\nHtml::$time-\u003euntilAbs('yesterday'); // -1 day\nHtml::$time-\u003ebetween('yesterday', 'tomorrow'); // 1 day\n```\n\n### Media embeds\nNormalize embed codes shared from media sites:\n\n```php\nuse DecodeLabs\\Tagged\\Embed\\Video;\n\necho Video::parse('https://www.youtube.com/watch?v=RG9TMn1FJzc');\n```\n\n## Components\n\nTagged also supports a higher level component abstraction allowing for more complex markup generation via the same interface. Components are called using an `@name` syntax:\n\n```php\nuse DecodeLabs\\Tagged as Html;\n\necho Html::{'@list'}($iterable, 'div.container', 'div.item', function($item) {\n    return Html::{'span'}($item);\n});\n\necho Html::{'@img'}('path/to/image.jpg', 'alt text');\n```\n\nSee the [components](./src/Tagged/Component) directory for a list of available components.\n\n## Licensing\nTagged is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Ftagged","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodelabs%2Ftagged","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Ftagged/lists"}