{"id":13610451,"url":"https://github.com/joelnet/html-lang","last_synced_at":"2026-02-14T13:38:47.510Z","repository":{"id":45170711,"uuid":"412646331","full_name":"joelnet/html-lang","owner":"joelnet","description":"HTML is a Programming Language!","archived":false,"fork":false,"pushed_at":"2022-01-03T22:43:55.000Z","size":862,"stargazers_count":303,"open_issues_count":0,"forks_count":8,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-08-01T19:55:07.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joelnet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-01T23:53:15.000Z","updated_at":"2024-06-12T21:05:22.000Z","dependencies_parsed_at":"2022-09-01T09:51:16.444Z","dependency_job_id":null,"html_url":"https://github.com/joelnet/html-lang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelnet%2Fhtml-lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelnet%2Fhtml-lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelnet%2Fhtml-lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelnet%2Fhtml-lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelnet","download_url":"https://codeload.github.com/joelnet/html-lang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223549257,"owners_count":17163628,"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":[],"created_at":"2024-08-01T19:01:44.821Z","updated_at":"2026-02-14T13:38:47.480Z","avatar_url":"https://github.com/joelnet.png","language":"HTML","readme":"# HTML is a Programming Language!\n\nHTML is now a Turing complete programming language with the `html-lang` library.\n\n`html-lang` is experimental and currently in development. So that means don't go slipping this into your production site! Proceed at your own risk!\n\n`html-lang` features no build step, no bundling, no webpack configs. Open up your HTML, include the script and start writing HTML.\n\nAt only 5.7kB (gzip) in size, `html-lang` is a tiny but powerful framework.\n\n## Why?\n\nMost frameworks are designed to be template engines. These typically mix their template language and JavaScript. Meaning you write and tie together both.\n\nWhile `html-lang` is similar to quite a bit of existing tech out there, the focus of this library is to bring that programming feel to HTML.\n\nThis allows you to stay inside the framework.\n\n## Install\n\nInclude the script tag into the `\u003chead\u003e\u003c/head\u003e` section of your HTML.\n\n```html\n\u003cscript src=\"https://unpkg.com/@joelnet/html-lang@0.1.1/umd/html-lang.js\"\u003e\u003c/script\u003e\n```\n\n## Variables\n\nVariables are globally scoped.\n\n```html\n\u003c!-- String --\u003e\n\u003cval message=\"Hello World\"\u003e\u003c/val\u003e\n\n\u003c!-- Number --\u003e\n\u003cval x:number=\"888\"\u003e\u003c/val\u003e\n\n\u003c!-- Boolean --\u003e\n\u003cval test:bool=\"true\"\u003e\u003c/val\u003e\n\n\u003c!-- Object --\u003e\n\u003cval y:object=\"{ x: 1, y: 2 }\"\u003e\u003c/val\u003e\n\n\u003c!-- Array --\u003e\n\u003cval z:object=\"['A', 'B', 'C']\"\u003e\u003c/val\u003e\n```\n\n## Computed Values\n\nThe computed value syntax has a `:?` at the end of the Variable name.\n\n```html\n\u003c!-- Set name --\u003e\n\u003cval name=\"World\"\u003e\u003c/val\u003e\n\n\u003c!-- Compute Message --\u003e\n\u003cval message:?=\"'Hello ' + name\"\u003e\u003c/val\u003e\n```\n\n## Output\n\nDisplay a Variable\n\n```html\n\u003c!-- set message to \"Hello World\" --\u003e\n\u003cval message=\"Hello World\"\u003e\u003c/val\u003e\n\n\u003c!-- Display message --\u003e\n\u003cspan #text=\"message\"\u003e\u003c/span\u003e\n```\n\n## If / Conditional\n\n```html\n\u003cif test=\"x \u003e 10\"\u003eX is GREATER than 10!\u003c/if\u003e\n```\n\nAn `else` can follow an `if` element.\n\n```html\n\u003cif test=\"x \u003e 10\"\u003eX is GREATER than 10!\u003c/if\u003e\n\u003celse\u003eX is NOT GREATER than 10!\u003c/else\u003e\n```\n\n## Loops\n\nA `for-of` loop will loop through all the items in the collection, setting the item to the variable specified.\n\n```html\n\u003c!-- Array --\u003e\n\u003cval todos:object=\"['Be nice to others', 'Drink water']\"\u003e\u003c/val\u003e\n\n\u003c!-- todo in todos --\u003e\n\u003cul todo:for:of=\"todos\"\u003e\n  \u003cli #text=\"todo\"\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c!-- \u003cul\u003e --\u003e\n\u003c!--   \u003cli\u003eBe nice to others\u003c/li\u003e --\u003e\n\u003c!--   \u003cli\u003eDrink water\u003c/li\u003e --\u003e\n\u003c!-- \u003c/ul\u003e --\u003e\n```\n\nA `for-in` loop will loop through all the items in the collection, setting the index to the variable specified.\n\n```html\n\u003c!-- Array --\u003e\n\u003cval todos:object=\"['Be nice to others', 'Drink water']\"\u003e\u003c/val\u003e\n\n\u003c!-- set i to 1 --\u003e\n\u003cul index:in=\"todos\"\u003e\n  \u003cli #text=\"index\"\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c!-- \u003cul\u003e --\u003e\n\u003c!--   \u003cli\u003e0\u003c/li\u003e --\u003e\n\u003c!--   \u003cli\u003e1\u003c/li\u003e --\u003e\n\u003c!-- \u003c/ul\u003e --\u003e\n```\n\n`for-of` and `for-in` can be combined together if they both point to the same collection.\n\n```html\n\u003c!-- Array --\u003e\n\u003cval todos:object=\"['Be nice to others', 'Drink water']\"\u003e\u003c/val\u003e\n\n\u003c!-- set i to 1 --\u003e\n\u003cul index:for:in=\"todos\" todo:for:of=\"todos\"\u003e\n  \u003cli\u003e\u003cspan #text=\"index+1\"\u003e\u003c/span\u003e. \u003cspan #text=\"todo\"\u003e\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003c!-- \u003cul\u003e --\u003e\n\u003c!--   \u003cli\u003e1. Be nice to others\u003c/li\u003e --\u003e\n\u003c!--   \u003cli\u003e2. Drink water\u003c/li\u003e --\u003e\n\u003c!-- \u003c/ul\u003e --\u003e\n```\n\n## Subroutines\n\nA Subroutine can be created to run common tasks. Subroutines take no arguments and return no values, but do have access to the variables.\n\n## Fetching Data\n\n```html\n\u003c!-- fetch data --\u003e\n\u003cval response:fetch=\"'https://swapi.dev/api/people/1'\"\u003e\u003c/val\u003e\n\n\u003c!-- destructure response into loading, error, data --\u003e\n\u003cval\n  loading:?=\"response.loading\"\n  error:?=\"response.error\"\n  data:?=\"response.json\"\n\u003e\u003c/val\u003e\n\n\u003c!-- Show when Loading --\u003e\n\u003cif test=\"loading\"\u003eLoading...\u003c/if\u003e\n\n\u003c!-- Show if Error --\u003e\n\u003cif test=\"error\"\u003e Error: \u003cspan #text=\"error\"\u003e\u003c/span\u003e \u003c/if\u003e\n\n\u003c!-- Display Data --\u003e\n\u003cif test=\"data\"\u003e\n  \u003cdiv\u003ename: \u003cspan #text=\"data.name\"\u003e\u003c/span\u003e\u003c/div\u003e\n  \u003cdiv\u003egender: \u003cspan #text=\"data.gender\"\u003e\u003c/span\u003e\u003c/div\u003e\n  \u003cdiv\u003eheight: \u003cspan #text=\"data.height\"\u003e\u003c/span\u003ecm\u003c/div\u003e\n\u003c/if\u003e\n```\n\n## Examples\n\n### FizzBuzz\n\n```html\n\u003c!-- loop through 1 to 100 --\u003e\n\u003cdiv num:for:of=\"range(1, 100)\"\u003e\n  \u003c!-- set fizz and buzz Booleans --\u003e\n  \u003cval fizz:?=\"num % 3 === 0\" buzz:?=\"num % 5 === 0\"\u003e\u003c/val\u003e\n\n  \u003cdiv\u003e\n    \u003c!-- Fizz Buzz --\u003e\n    \u003cif test=\"fizz\"\u003eFizz\u003c/if\u003e\u003cif test=\"buzz\"\u003eBuzz\u003c/if\u003e\n\n    \u003c!-- no match --\u003e\n    \u003cif test=\"!fizz \u0026\u0026 !buzz\"\u003e\n      \u003cspan #text=\"num\"\u003e\u003c/span\u003e\n    \u003c/if\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n### TODO List\n\n```html\n\u003cval todos:object=\"['Be nice to others', 'Drink water']\"\u003e\u003c/val\u003e\n\n\u003cinput type=\"text\" bind:value=\"newtodo\" /\u003e\n\u003cbutton on:click:todos=\"[...todos, newtodo]\"\u003eadd\u003c/button\u003e\n\n\u003chr /\u003e\n\n\u003cdiv watch=\"todos\"\u003e\n  \u003cul todo:for:of=\"todos\"\u003e\n    \u003cli\u003e\n      \u003cbutton on:click:todos=\"todos.filter((item) =\u003e item !== todo)\"\u003eX\u003c/button\u003e\n      \u003cspan #text=\"todo\"\u003e\u003c/span\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/div\u003e\n```\n\n### Dialog\n\n```html\n\u003cval open:bool=\"false\"\u003e\u003c/val\u003e\n\n\u003cdiv watch=\"open\"\u003e\n  \u003cbutton on:click:open=\"!open\" #text=\"open ? 'Close' : 'Open'\"\u003e\u003c/button\u003e\n\n  \u003cdialog #open=\"open\"\u003e\n    \u003ch2\u003eHello Dialog!\u003c/h2\u003e\n  \u003c/dialog\u003e\n\u003c/div\u003e\n```\n\n### More Examples\n\n- [Memory Game](https://codepen.io/joelnet/pen/BadymQz)\n- [Calculator](https://codepen.io/joelnet/pen/porzEPv)\n\n## Alternatives\n\n- [Alpine.js](https://alpinejs.dev/) — Alpine is a rugged, minimal tool for composing behavior directly in your markup. Think of it like jQuery for the modern web. Plop in a script tag and get going.\n","funding_links":[],"categories":["HTML"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelnet%2Fhtml-lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelnet%2Fhtml-lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelnet%2Fhtml-lang/lists"}