ob:embed & ob:html¶
ob:embed (Go-Style Embedded Files)¶
Read static assets (HTML templates, SQL migrations, JSON configs, CSS) seamlessly across development and production:
- In development (
ob run): reads directly from your project directory on disk. - In production (
ob build --compile): reads straight from the in-memory archive embedded inside the standalone executable — no external files or--allow-readneeded.
API¶
embed.read(rel_path)— returns the embedded file contents as a string.embed.exists(rel_path)— returnsboolean.embed.list()— returns a sorted array of all embedded asset paths.
local embed = require("ob:embed")
if embed.exists("assets/banner.txt") then
print(embed.read("assets/banner.txt"))
end
ob:html (SSR Templates & .luax Engine)¶
Provides server-side HTML rendering for both Angular/Vue-style .html templates and .luax / .tylx components:
html.template(rel_path, data?)— loads, compiles (cached in memory via Layer 1 cache), and renders an.htmltemplate file withdata. Works identically from disk (ob run) and inside compiled binaries (ob build --compile).html.render_template(raw_html, data?)— compiles and renders an inline.htmltemplate string.html.asset(path)— resolves a static asset path to a content-hashed URL (e.g."/public/styles.css?v=9f3a1c2d"). Also injected automatically asasset(...)inside every.htmltemplate.html.raw(raw_html)— wraps pre-rendered HTML so it is inserted without escaping.html.island(name, props?, fallback?)— emits a client-side hydration island container (data-orb-island+data-orb-props).html.jsx(tag, props?, children?)— creates a VNode or invokes a function component.html.render(node)— recursively renders VNodes, fragments, and arrays to HTML with automatic text and attribute escaping.html.escape(text)— escapes&,<,>,", and'.
local html = require("ob:html")
-- Render a reusable .html component template
local card = html.template("apps/tasks/components/task_card/task_card.html", {
title = "Ship Orbita v0.2",
done = false,
})
-- Versioned asset URL
local css_url = html.asset("styles.css") -- "/public/styles.css?v=9f3a1c2d"
-- Direct VNode rendering
local node = html.jsx("div", { class = "alert" }, { "Safe against <script>" })
print(html.render(node))
-- <div class="alert">Safe against <script></div>