{"id":31111914,"url":"https://github.com/jonathanwthom/ruby_html","last_synced_at":"2026-06-30T02:31:33.929Z","repository":{"id":82273339,"uuid":"132098667","full_name":"JonathanWThom/ruby_html","owner":"JonathanWThom","description":"Build HTML with Ruby","archived":false,"fork":false,"pushed_at":"2018-05-11T04:46:19.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T08:45:30.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/JonathanWThom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-05-04T06:37:08.000Z","updated_at":"2018-05-11T04:46:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"cca78939-670f-47df-b875-b27c04b50f13","html_url":"https://github.com/JonathanWThom/ruby_html","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/JonathanWThom/ruby_html","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanWThom%2Fruby_html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanWThom%2Fruby_html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanWThom%2Fruby_html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanWThom%2Fruby_html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonathanWThom","download_url":"https://codeload.github.com/JonathanWThom/ruby_html/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanWThom%2Fruby_html/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34950328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-09-17T08:29:59.019Z","updated_at":"2026-06-30T02:31:33.912Z","avatar_url":"https://github.com/JonathanWThom.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby HTML\n\nAn HTML document builder in Ruby.\n\n### Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"ruby_html\"\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ruby_html\n\n### How to Use It\n\nHTML elements have the names you think they would. For example, to create a div:\n\n```\ndiv = HTML::Div.new\n```\n\nElements can receive arguments. These can be strings, or can be other elements themselves.\nThese elements will be nested under their parent.\n\n```\ndiv = HTML::Div.new(\"Hello\", HTML::P.new(\"World\"))\n```\n\nYou can also add new elements to a previously created element with `#add_elements`, which accepts any number of arguments.\n\n```\ndiv.add_elements(\"Hello\")\ndiv.add_elements(\"Hello\", \"From\", HTML::H3.new(\"Earth\"))\n```\n\nYou can pass the same element as an argument as many times as you want - just like a partial or component.\n\nAll elements have a method `#render`, which prints all the element's contents (calling `.render` on all non string elements\ncontained within.\n\n```\ndiv = HTML::Div.new(HTML::H6.new(\"Hello\"), \"World\")\ndiv.render\n=\u003e \"\u003cdiv\u003e\u003ch6\u003eHello\u003c/h6\u003eWorld\u003c/div\u003e\"\n```\n\nTo add attributes to an element, pass a hash to the object like so:\n\n```\np_with_class = HTML::P.new(\"Hello World\", attributes: { \"class\": \"red\" })\np_with_class.render\n=\u003e \u003cp class='red'\u003eHello World\u003c/p\u003e\n```\n\nMost importantly, if you want to actually create an HTML page, you'll want to create a `Document` that holds all of your elements.\nA document recieves elements, as well as header elements (such as `\u003ctitle\u003e` or `\u003cstyle\u003e`).\n\n```\ntitle = HTML::Title.new(\"Page Title\")\nDocument.new(HTML::Div.new, header_elements: [title])\n```\n\n`Document` has a special method, `#render_to_file` that receives a file path, and creates your html document there.\n\n```\nHTML::Document.new.render_to_file(\"hello_world.html\")\n=\u003e creates html document\n```\n\n\n### TODO\n\n- Build out remaining elements. There are a few that conflict with ruby (such as `Object`). This should not be an issue anymore\nnow that the `HTML` namespace has been added.\n- Code clean up (alphabetical order, some methods probably don't need to be public, etc).\n- The single quotes for attributes are a bit weird, and you might not always want those.\n- Example in the docs of how to use with Rails, and maybe a full document built with ruby_html.\n\n### Contributing\n\n1. Fork it\n2. Clone it\n3. Make a PR.\n4. Be kind to others. Programming is fun.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanwthom%2Fruby_html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanwthom%2Fruby_html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanwthom%2Fruby_html/lists"}