{"id":37037524,"url":"https://github.com/ninjacoder88/html-builder","last_synced_at":"2026-01-14T04:28:07.195Z","repository":{"id":200426797,"uuid":"694808858","full_name":"ninjacoder88/html-builder","owner":"ninjacoder88","description":"A Utility to Help Build HTML documents","archived":false,"fork":false,"pushed_at":"2024-09-27T03:53:13.000Z","size":313,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T20:20:00.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/ninjacoder88.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}},"created_at":"2023-09-21T18:30:01.000Z","updated_at":"2023-09-21T21:15:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"b76b5da8-92ab-4c12-bbba-0747182fc3fe","html_url":"https://github.com/ninjacoder88/html-builder","commit_stats":null,"previous_names":["ninjacoder88/html-builder"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ninjacoder88/html-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjacoder88%2Fhtml-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjacoder88%2Fhtml-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjacoder88%2Fhtml-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjacoder88%2Fhtml-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ninjacoder88","download_url":"https://codeload.github.com/ninjacoder88/html-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ninjacoder88%2Fhtml-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":"2026-01-14T04:28:06.524Z","updated_at":"2026-01-14T04:28:07.188Z","avatar_url":"https://github.com/ninjacoder88.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ninjasoft.HtmlBuilder\n\n## Purpose\nThe purpose of this project is to provide a utility to build webpages (or any HTML content) in code.\n\n## Usage\nStart by creating a new instance of `HtmlDocument` in the following way\n```\nvar document = new HtmlDocument();\n```\n\nThis is setup as a builder pattern so the last method that should be called is `Build` which returns the entire HTML string.\n\nFrom `HtmlDocument` there are a number of methods available: `AddBody`, `AddHead`, `SetAttribute`, `SetClass`. The last two methods are available on almost every subsequent builder. As mentioned previously, this uses the builder pattern to create HTML documents. Most of the builders have subsequent builders that can be utilized to build more complex HTML.\n\n## Examples\nBelow is an example of a fairly simple webpage.\n```\nvar html = new HtmlDocument()\n    .AddHead(head =\u003e \n        head.AddMeta(meta =\u003e meta.Set(\"name\", \"viewport\").Set(\"content\", \"width=device-width, initial-scale=1.0\"))\n            .AddMeta(meta =\u003e meta.Set(\"charset\", \"utf-8\"))\n            .SetTitle(\"HTML Builder\")\n            .AddLink(link =\u003e link.SetRel(\"stylesheet\").SetType(\"text/css\").SetHref(\"css/lib/bootstrap-5.1.3.min.css\")))\n    .AddBody(body =\u003e \n        body.AddDiv(div =\u003e div.SetClass(\"container\")\n                .AddHeading(Heading.H1, \"HTML Builder\")\n                .AddForm(form =\u003e form.SetId(\"form1\")\n                    .AddDiv(div =\u003e div.SetClass(\"mb-3\")\n                        .AddLabel(\"Name\")\n                        .AddInput(InputType.Text, input =\u003e input.SetClass(\"form-control\"))\n                    )\n                    .AddDiv(div =\u003e div.SetClass(\"mb-3\")\n                        .AddLabel(\"Quantity\")\n                        .AddSelect(select =\u003e select.SetClass(\"form-control\")\n                            .AddOption(\"Option 1\")\n                            .AddOption(\"Option 2\"))\n                        )\n                    .AddDiv(div =\u003e div.SetClass(\"mb-3\")\n                        .AddLabel(\"Notes\")\n                        .AddTextarea(textarea =\u003e textarea.SetClass(\"form-control\")))\n                )\n                .AddButton(button =\u003e button.SetType(ButtonType.Button).SetClass(\"btn btn-primary\").SetText(\"Load\"))\n                .AddHorizontalRule()\n                .AddTable(table =\u003e\n                    table.SetClass(\"table\")\n                    .AddHead(thead =\u003e thead.AddRow(tr =\u003e tr.AddDataHeading(\"Name\").AddDataHeading(\"Address\")))\n                    .AddBody(tbody =\u003e tbody.AddRow(tr =\u003e tr.AddData(\"John Doe\").AddData(\"123 Fake St\")))\n                )\n                .AddHorizontalRule()\n                .AddDiv(d =\u003e d.AddHtml(\"\u003cp\u003eCustom HTML\u003c/p\u003e\"))\n                .AddParagraph(\"\")\n                .AddLineBreak()\n                .AddAnchor(a =\u003e a.SetValue(\"Click Here\").SetHref(\"#\"))\n                .AddLineBreak()\n                .AddImage(\"images/transparent-ninjasoft-nuget.png\")\n                .AddList(ListType.UnorderedList, ul =\u003e \n                    ul.Add(\"Item 1\")\n                        .Add(\"Item 2\")\n                        .Add(\"Item 3\"))\n            )\n            .AddScript(ScriptType.JavaScript, \"js/lib/jquery-3.6.0.min.js\")\n            .AddScript(ScriptType.JavaScript, \"js/lib/bootstrap.bundle-5.1.3.min.js\")\n        )\n    .Build();\n```\n\nBuild head and body independently\n```\nHeadBuilder headBuilder = new HeadBuilder();\nheadBuilder.AddMeta(meta =\u003e meta.Set(\"name\", \"viewport\").Set(\"content\", \"width=device-width, initial-scale=1.0\"))\n        .AddMeta(meta =\u003e meta.Set(\"charset\", \"utf-8\"))\n        .SetTitle(\"HTML Builder\")\n        .AddLink(link =\u003e link.SetRel(\"stylesheet\").SetType(\"text/css\").SetHref(\"css/lib/bootstrap-5.1.3.min.css\"));\n\nBodyBuilder bodyBuilder = new BodyBuilder();\nbodyBuilder.AddDiv(div =\u003e div.SetClass(\"container\")\n        .AddHeading(Heading.H1, \"HTML Builder\")\n        .AddForm(form =\u003e form.SetId(\"form1\")\n            .AddDiv(div =\u003e div.SetClass(\"mb-3\")\n                .AddLabel(\"Name\")\n                .AddInput(InputType.Text, input =\u003e input.SetClass(\"form-control\"))\n            )\n            .AddDiv(div =\u003e div.SetClass(\"mb-3\")\n                .AddLabel(\"Quantity\")\n                .AddSelect(select =\u003e select.SetClass(\"form-control\")\n                    .AddOption(\"Option 1\")\n                    .AddOption(\"Option 2\"))\n                )\n            .AddDiv(div =\u003e div.SetClass(\"mb-3\")\n                .AddLabel(\"Notes\")\n                .AddTextarea(textarea =\u003e textarea.SetClass(\"form-control\")))\n        )\n        .AddButton(button =\u003e button.SetType(ButtonType.Button).SetClass(\"btn btn-primary\").SetText(\"Load\"))\n        .AddHorizontalRule()\n        .AddTable(table =\u003e\n            table.SetClass(\"table\")\n            .AddHead(thead =\u003e thead.AddRow(tr =\u003e tr.AddDataHeading(\"Name\").AddDataHeading(\"Address\")))\n            .AddBody(tbody =\u003e tbody.AddRow(tr =\u003e tr.AddData(\"John Doe\").AddData(\"123 Fake St\")))\n        )\n        .AddHorizontalRule()\n        .AddDiv(d =\u003e d.AddHtml(\"\u003cp\u003eCustom HTML\u003c/p\u003e\"))\n        .AddParagraph(\"\")\n        .AddLineBreak()\n        .AddAnchor(a =\u003e a.SetValue(\"Click Here\").SetHref(\"#\"))\n        .AddLineBreak()\n        .AddImage(\"images/transparent-ninjasoft-nuget.png\")\n        .AddList(ListType.UnorderedList, ul =\u003e \n            ul.Add(\"Item 1\")\n                .Add(\"Item 2\")\n                .Add(\"Item 3\"))\n    )\n    .AddScript(ScriptType.JavaScript, \"js/lib/jquery-3.6.0.min.js\")\n    .AddScript(ScriptType.JavaScript, \"js/lib/bootstrap.bundle-5.1.3.min.js\");\n        \n\nvar html = new HtmlDocument()\n    .AddHead(headBuilder)\n    .AddBody(bodyBuilder)\n    .Build();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninjacoder88%2Fhtml-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fninjacoder88%2Fhtml-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninjacoder88%2Fhtml-builder/lists"}