mirror of
https://codeberg.org/setop/elm-scripting
synced 2025-11-08 21:49:57 +00:00
34aaeaccc148820dec7fbbbbae08665050b4d40d
A tool to generate HTML code from Elm source in the terminal using QuickJS.
Design
QuickJS (Qjs) is a JavaScript runtime, similar to V8 or SpiderMonkey, but lighter and faster.
As any runtime, Qjs can interpret JavaScript code, but it is not a web browser. It has no concept of an HTML document.
To bridge this gap, we add a minimal DOM implementation.
Next, we concatenate this with the Elm JavaScript output and an app launcher snippet, then ask Qjs to interpret all of it.
Limitations
- No event loop
- Hence, no TEA; the
mainfunction must return a static view - The Elm app module must be called "Main"
- Nodes can only have one parent (this should always be the case)
Usage
- Clone this repository and navigate into your local copy
- Run
elm init. - Create
src/Main.elmwith the following content:
module Main exposing(main)
import Html exposing (p, text)
main = p [] [text "Hello World!"]
- Run
./build.sh; this generates the corresponding HTML code:
<p>
Hello World!
</p>
Prior Work
There are more complete tools for generating static sites with Elm:
You should probably consider using one of them instead of this one. :)
Description
Languages
JavaScript
75.2%
Shell
24.8%