{"id":15063589,"url":"https://github.com/tkdeng/htmlc","last_synced_at":"2026-01-02T00:01:38.789Z","repository":{"id":255672844,"uuid":"846966381","full_name":"tkdeng/htmlc","owner":"tkdeng","description":"Compiles HTML to Elixir. Who says HTML is not a programming language?","archived":false,"fork":false,"pushed_at":"2024-12-14T02:13:56.000Z","size":58918,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T08:35:46.437Z","etag":null,"topics":["compiler","elixir","exs","go","golang","html","html5","htmlc","iex","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Go","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/tkdeng.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T13:16:21.000Z","updated_at":"2024-12-14T02:13:59.000Z","dependencies_parsed_at":"2024-09-06T17:18:42.979Z","dependency_job_id":"a55074a4-b731-4b08-b937-866a1d6201fc","html_url":"https://github.com/tkdeng/htmlc","commit_stats":null,"previous_names":["tkdeng/htmlc"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fhtmlc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fhtmlc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fhtmlc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkdeng%2Fhtmlc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkdeng","download_url":"https://codeload.github.com/tkdeng/htmlc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243778794,"owners_count":20346617,"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":["compiler","elixir","exs","go","golang","html","html5","htmlc","iex","template-engine"],"created_at":"2024-09-25T00:04:40.360Z","updated_at":"2026-01-02T00:01:38.781Z","avatar_url":"https://github.com/tkdeng.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTMLC (HTML Compiler)\n\n[\u003cimg src=\"./assets/icon.png\" alt=\"icon\" height=\"100\"/\u003e](./assets/icon.png)\n\nCompiles HTML to Elixir.\nWho says HTML is not a programming language?\n\nThis module is just another templating engine.\nWith elixir, we can leverage its ability to call individual functions in `iex` mode.\nElixir can quickly build templates on the fly.\n\n\u003e Notice: This Project Is Still In Beta.\n\n## Installation\n\n```shell\n# install the go module\ngo get github.com/tkdeng/htmlc\n\n# or install the binary\ngit clone https://github.com/tkdeng/htmlc.git \u0026\u0026\\\ncd htmlc \u0026\u0026\\\nmake install \u0026\u0026\\\ncd ../ \u0026\u0026 rm -r htmlc\n\n# install into /usr/bin\nmake install\n\n# install locally (with dependencies)\nmake local\n\n# build without dependency installation\nmake build\n\n# install dependencies\nmake deps\n\n# uninstall htmlc\nmake clean\n```\n\n## Golang Usage\n\n```go\nimport (\n  \"github.com/tkdeng/htmlc\"\n)\n\nfunc main(){\n  htmlc.Compile(\"./src\", \"./output.exs\")\n\n  engine, err := htmlc.Engine(\"./output.exs\")\n\n  // on page request\n  buf, err := engine.Render(\"index\", htmlc.Map{\"args\": \"my args\"}, \"layout\")\n}\n```\n\n## Gofiber Usage\n\n```go\nimport (\n  \"github.com/gofiber/fiber/v3\"\n  htmlcfiber \"github.com/tkdeng/htmlc/gofiber\"\n)\n\nfunc main(){\n  engine, err := htmlcfiber.New(\"./src\")\n  if err != nil {\n    panic(err)\n  }\n\n  app := fiber.New(fiber.Config{\n    Views: engine,\n  })\n\n  app.Get(\"/\", func(c fiber.Ctx) error {\n    return c.Render(\"index\", fiber.Map{\"title\": \"Test\"}, \"layout\")\n  })\n\n  app.Listen(\":3000\")\n}\n```\n\n## Binary Usage\n\n```shell\nhtmlc ./src --out=\"./output.exs\"\n```\n\nYou can also specify a port number, to automatically start a static-like http server.\n\n```shell\nhtmlc ./src --port=\"3000\"\n```\n\nNote: by default, \"--out\" is set to the same directory, with the file name set to the base folder name.\n\n## Elixir Template Usage\n\n```shell\n# compile\nhtmlc ./src\n\n# start template engine\nelixir ./html.exs\n\n# render page\n\u003e render, mypage/home, mylayout/layout, eyJqc29uIjogImFyZ3MifQ==\n#                                       base64({\"json\": \"args\"})\n\n# render widget (optional)\n\u003e widget, mywidget/app, eyJqc29uIjogImFyZ3MifQ==\n#                       base64({\"json\": \"args\"})\n\n# render layout (optional)\n\u003e layout, mylayout/layout, eyJqc29uIjogImFyZ3MifQ==, eyJqc29uIjogImh0bWwgY29udGVudCJ9\n#                          base64({\"json\": \"args\"}), base64({\"json\": \"html content\"})\n\n# stop template engine\nstop\n```\n\n### IEX Template Usage\n\n```elixir\n# compile\nhtmlc --iex ./src\n\n# start template engine\niex ./html.exs\n\n# render page\niex\u003e App.render \"mypage/home\", \"mylayout/layout\", %{args: \"myarg\"}\n\n# render widget (optional)\niex\u003e App.widget \"mywidget/app\", %{args: \"myarg\"}\n\n# render layout (optional)\niex\u003e App.layout \"mylayout/layout\", %{args: \"myarg\"}, %{body: \"page embed\"}\n\n# stop template engine\niex\u003e System.halt\n```\n\n## HTML Templates\n\n### Layout\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"/\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0\"/\u003e\n  \u003cmeta name=\"description\" content=\"{desc}\"/\u003e\n  \u003ctitle\u003e{title}\u003c!-- {variable} --\u003e\u003c/title\u003e\n  {@head} \u003c!-- embed page head --\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  {@body} \u003c!-- embed page body --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Page\n\n```html\n\u003c_@head\u003e \u003c!-- embed into layout {@head} reference --\u003e\n  \u003clink rel=\"stylesheet\" href=\"/style.css\"\u003e\n\u003c/_@head\u003e\n\n\u003c_@body\u003e \u003c!-- embed into {@body} --\u003e\n  \u003ch1\u003eHello, World\u003c/h1\u003e\n\n  \u003c!-- use `\u003c_#name\u003e` to embed widgets --\u003e\n  \u003c_#app n=\"2\"\u003e\n    widget body\n  \u003c/_#app\u003e\n\n  \u003cmain\u003e\n    {\u0026main} \u003c!-- {\u0026variable} use `\u0026` to allow raw HTML --\u003e\n  \u003c/main\u003e\n\u003c/_@body\u003e\n```\n\n### Widget\n\n```html\n\u003cdiv class=\"widget\"\u003e\n  \u003c!-- use \u003c% scripts %\u003e to run elixir (feature not yet implemented) --\u003e\n  {n} * 2 = \u003c%\n    args.n * 2\n  %\u003e\n\u003c/div\u003e\n\n\u003c!-- markdown not yet implemented --\u003e\n\u003cmd\u003e\n  Markdown\n\u003c/md\u003e\n\n\u003cmarkdown\u003e\n  Markdown\n\u003c/markdown\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fhtmlc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkdeng%2Fhtmlc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkdeng%2Fhtmlc/lists"}