{"id":19764363,"url":"https://github.com/brick/html","last_synced_at":"2025-04-30T14:32:57.474Z","repository":{"id":62497042,"uuid":"106001110","full_name":"brick/html","owner":"brick","description":"A simple HTML 5 generation library","archived":false,"fork":false,"pushed_at":"2024-05-02T23:20:50.000Z","size":27,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-06T22:35:54.149Z","etag":null,"topics":["html","html-tags","php"],"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/brick.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}},"created_at":"2017-10-06T12:17:16.000Z","updated_at":"2024-10-01T13:38:56.000Z","dependencies_parsed_at":"2023-01-23T10:32:25.700Z","dependency_job_id":null,"html_url":"https://github.com/brick/html","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick%2Fhtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick%2Fhtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick%2Fhtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brick%2Fhtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brick","download_url":"https://codeload.github.com/brick/html/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224214016,"owners_count":17274524,"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","html-tags","php"],"created_at":"2024-11-12T04:13:37.327Z","updated_at":"2024-11-12T04:13:38.104Z","avatar_url":"https://github.com/brick.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Brick\\Html\n\n\u003cimg src=\"https://raw.githubusercontent.com/brick/brick/master/logo.png\" alt=\"\" align=\"left\" height=\"64\"\u003e\n\nA very simple HTML 5 generation library.\n\n[![Build Status](https://github.com/brick/html/workflows/CI/badge.svg)](https://github.com/brick/html/actions)\n[![Coverage Status](https://coveralls.io/repos/github/brick/html/badge.svg?branch=master)](https://coveralls.io/github/brick/html?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/brick/html/v/stable)](https://packagist.org/packages/brick/html)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)\n\n## Installation\n\nThis library is installable via [Composer](https://getcomposer.org/):\n\n```bash\ncomposer require brick/html\n```\n\n## Requirements\n\nThis library requires PHP 7.1 or later.\n\n## Project status \u0026 release process\n\nThis library is still under development.\n\nThe current releases are numbered `0.x.y`. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), `y` is incremented.\n\n**When a breaking change is introduced, a new `0.x` version cycle is always started.**\n\nIt is therefore safe to lock your project to a given release cycle, such as `0.1.*`.\n\nIf you need to upgrade to a newer release cycle, check the [release history](https://github.com/brick/html/releases) for a list of changes introduced by each further `0.x.0` version.\n\n## Introduction\n\nThis library contains a single class, `Tag`, that represents an HTML tag. You construct a `Tag` using a tag name:\n\n```php\nuse Brick\\Html\\Tag;\n\n$div = new Tag('div');\n```\n\n### Attributes\n\nYou can pass an optional associative array of attributes to the constructor:\n\n```php\n$div = new Tag('div', [\n    'id' =\u003e 'main',\n    'class' =\u003e 'block',\n]);\n```\n\nOr you can set attributes later:\n\n```php\n$tag-\u003esetAttributes([\n    'id' =\u003e 'main',\n    'class' =\u003e 'block',\n]);\n```\n\nOr:\n\n```php\n$tag-\u003esetAttribute('id', 'main')\n    -\u003esetAttribute('class', 'block');\n```\n\nYou can also remove attributes:\n\n```php\n$tag-\u003eremoveAttribute('id');\n```\n\n### Content\n\nYou can set the content of a `Tag`, provided that it's not a *void* tag such as `\u003cbr\u003e`, `\u003cinput\u003e`, etc. \nIf you try to modify the content of a void tag, you'll get a `LogicException`.\n\nYou can set or append a plain text content:\n\n```php\n$tag-\u003esetTextContent('Hello, world!');\n$tag-\u003eappendTextContent(\"\\nWhat's up?\");\n```\n\nOr set/append a HTML content:\n\n```php\n$tag-\u003esetHtmlContent('Hello, \u003cb\u003eworld!\u003c/b\u003e');\n$tag-\u003eappendHtmlContent(\"\u003cbr\u003eWhat's up?\");\n```\n\nYou can also append another `Tag`:\n\n```php\n$tag-\u003eappend($otherTag);\n```\n\nYou can remove the content of a `Tag`:\n\n```php\n$tag-\u003eempty();\n```\n\nYou can check if a `Tag` has an empty content:\n\n```php\n$tag-\u003eisEmpty(); // boolean\n```\n\n### Rendering a tag\n\nYou can render a tag by using its `render()` method, or just by casting it to string:\n\n```php\necho $tag; // will output something like: \u003cdiv id=\"main\"\u003eHello, world!\u003c/div\u003e\n```\n\n### Encoding\n\nAll texts (attributes, content) are expected to be valid UTF-8.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrick%2Fhtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrick%2Fhtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrick%2Fhtml/lists"}