Skip to content

Search titles, headings, and documentation content.

↑↓ navigate Enter open Esc close

    Browse documentation
    On this page

    Lua

    Lua runs during the build. You can embed it inside HTML or write build hooks which run before or after compilation.

    Inline Lua

    Inline Lua runs while HTML is being built, emits ordinary nodes, and disappears from the final document.

    <script type="application/x-sklair-lua">
      sklair.html("<p>Built at " .. os.date("%H:%M") .. "</p>")
    </script>
    

    Use it when HTML structure genuinely depends on data or computation: generating a navigation tree, rendering a Markdown-derived table of contents, or adapting one component to structured input. Props and bindings should handle the simple cases. Lua handles the cases where pretending HTML is an expression language would be worse.

    Inline Lua has two execution modes:

    • dynamic Lua runs for each document, component, or layout instance;
    • static Lua runs once while a used definition is prepared, and its unresolved output is reused (effectively cached).

    See Inline Lua for the syntax and static/dynamic execution modes, and Emitting markup for the output functions.

    Shared environment and libraries

    Lua environment describes the available standard libraries, execution scopes, diagnostics, and os.exit. Filesystem lists the namespaces and permissions for inline Lua and both hook phases.

    The JSON, Markdown, and JSON Schema libraries are available in both inline Lua and hooks.