https://github.com/rokf/lua-html
Generate HTML from tables
https://github.com/rokf/lua-html
generator html
Last synced: about 1 month ago
JSON representation
Generate HTML from tables
- Host: GitHub
- URL: https://github.com/rokf/lua-html
- Owner: rokf
- License: mit
- Created: 2017-09-10T13:47:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-14T17:58:45.000Z (almost 9 years ago)
- Last Synced: 2025-10-27T05:37:02.391Z (10 months ago)
- Topics: generator, html
- Language: Lua
- Homepage:
- Size: 3.91 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
lua-html
This is a Lua 5.1 / LuaJIT module which can generate HTML
by combining functions, tables and their metatables.
It uses the `__index` metatable field to replace undefined
function calls with HTML strings.
The metatable of the module itself has a `__call` field.
After the module is required it can be called as a function.
The function accepts three arguments. A function,
a data table (optional) and a custom environment table (optional).
The function runs inside a custom
environment so you can still get those `undefined` errors
outside of it.
Every function which doesn't exist inside the environment
gets replaced by a HTML element (string) with its name. It accepts
a table. Key - value pairs are turned into attributes, the rest is
converted into a string and put inside the element.