{"id":13785270,"url":"https://github.com/sahandnayebaziz/Hypertext","last_synced_at":"2025-05-11T20:32:49.947Z","repository":{"id":56914748,"uuid":"72308491","full_name":"sahandnayebaziz/Hypertext","owner":"sahandnayebaziz","description":"Any-way-you-want-it, type-safe HTML in Swift.","archived":true,"fork":false,"pushed_at":"2017-09-23T03:01:06.000Z","size":2129,"stargazers_count":233,"open_issues_count":0,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-06T19:48:45.245Z","etag":null,"topics":["dsl","html","markup","server","server-side-swift","swift","type-safe"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/sahandnayebaziz.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}},"created_at":"2016-10-29T20:46:20.000Z","updated_at":"2025-04-06T17:46:52.000Z","dependencies_parsed_at":"2022-08-20T20:50:38.030Z","dependency_job_id":null,"html_url":"https://github.com/sahandnayebaziz/Hypertext","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/sahandnayebaziz%2FHypertext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahandnayebaziz%2FHypertext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahandnayebaziz%2FHypertext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahandnayebaziz%2FHypertext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sahandnayebaziz","download_url":"https://codeload.github.com/sahandnayebaziz/Hypertext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253632336,"owners_count":21939374,"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":["dsl","html","markup","server","server-side-swift","swift","type-safe"],"created_at":"2024-08-03T19:00:58.659Z","updated_at":"2025-05-11T20:32:48.971Z","avatar_url":"https://github.com/sahandnayebaziz.png","language":"Swift","funding_links":[],"categories":["Utility"],"sub_categories":["Strings"],"readme":"![header](header.jpg)\n\nCompose valid HTML in Swift any way you want to.\n\n### Usage\n\n````swift\n\nimport Hypertext\n\ntitle { \"hello world.\" }.render()\n// \u003ctitle\u003ehello world.\u003c/title\u003e\n\nhead { title { \"hello world.\" } }.render()\n// \u003chead\u003e\u003ctitle\u003ehello world.\u003c/title\u003e\u003c/head\u003e\n\nhead { title { \"hello world.\" } }.render(startingWithSpaces: 0, indentingWithSpaces: 2)\n// \u003chead\u003e\n//   \u003ctitle\u003e\n//     hello world.\n//   \u003c/title\u003e\n// \u003c/head\u003e\n\n````\n\n\n\n### Requirements\n- Swift 3.0+\n\n### Full usage\n\n1. Rendering a tag\n\n    ```swift\n\n    div().render() \n    // \u003cdiv\u003e\u003c/div\u003e\n\n    ```\n    \n2. Rendering a tag with child text\n\n   ```swift\n   \n   div { \"hello world.\" }.render()\n   // \u003cdiv\u003ehello world.\u003c/div\u003e\n   \n   ```\n   \n3. Rendering a tag with a child tag\n\n   ```swift\n   \n   div { img() }.render()\n   // \u003cdiv\u003e\u003cimg/\u003e\u003c/div\u003e\n   \n   ```\n   \n4. Rendering a tag with multiple child tags\n\n   ```swift\n   \n   div { [img(), img(), img()] }.render()\n   // \u003cdiv\u003e\u003cimg/\u003e\u003cimg/\u003e\u003cimg/\u003e\u003c/div\u003e\n   \n   ```\n   \n5. Rendering a tag with attributes\n\n   ```swift\n   \n   link([\"rel\": \"stylesheet\", \"type\":\"text/css\", \"href\":\"./style.css\"]).render()\n   // \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"./style.css\"/\u003e\n   \n   ```\n   \n6. Rendering a tag with attributes and children\n\n   ```swift\n   \n   div([\"class\": \"container\"]) { \"hello world.\" }\n   // \u003cdiv class=\"container\"\u003ehello world.\u003c/div\u003e\n   \n   ```\n\n7. Rendering a doctype declaration\n\n   ```swift\n   doctype(.html5).render()\n   // \u003c!DOCTYPE html\u003e\n   ```\n\n8. Rendering unminified, with newlines and indentation\n\n    ```swift\n    \n    head { title { \"hello world.\" } }.render(startingWithSpaces: 0, indentingWithSpaces: 2)\n    // \u003chead\u003e\n    //   \u003ctitle\u003e\n    //     hello world.\n    //   \u003c/title\u003e\n    // \u003c/head\u003e\n    \n    ```\n    \n9. Rendering a tag in a novel way, any way you want to\n\n   ```swift\n   \n   func createTitleTag(forPageNamed pageName: String) -\u003e title {\n     return title { \"Hypertext - \\(pageName)\" }\n   }\n   \n   head { createTitleTag(forPageNamed: \"Documentation\") }.render()\n   // \u003chead\u003e\u003ctitle\u003eHypertext - Documentation\u003c/title\u003e\u003c/head\u003e\n   \n   ```\n   \n10. Rendering a custom tag\n\n       ```swift\n\n       public class myNewTag: tag {\n\n         override public var isSelfClosing: Bool { \n           return true \n         }\n       }\n\n       myNewTag().render()\n       // \u003cmy-new-tag/\u003e\n\n       ```\n   \n11. Rendering a custom type by adopting the protocol `Renderable`\n\n       ```swift\n\n       extension MyType: Renderable {\n         public func render() -\u003e String { ... }\n         public func render(startingWithSpaces: Int, indentingWithSpaces: Int) -\u003e String { ... }\n       }\n\n       ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsahandnayebaziz%2FHypertext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsahandnayebaziz%2FHypertext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsahandnayebaziz%2FHypertext/lists"}