Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eeue56/elm-static-html
Statically render html from Elm!
https://github.com/eeue56/elm-static-html
Last synced: about 1 month ago
JSON representation
Statically render html from Elm!
- Host: GitHub
- URL: https://github.com/eeue56/elm-static-html
- Owner: eeue56
- License: bsd-3-clause
- Created: 2016-11-29T23:54:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-26T09:30:12.000Z (over 7 years ago)
- Last Synced: 2024-11-08T08:07:55.514Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 87
- Watchers: 11
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-static-html
Turn an Elm app into a static HTML site.
Your modules must look like this:
```elm
module Main exposing (..)import Html
import Html.Attributes exposing (class, href)view : Html.Html msg
view =
Html.div []
[ Html.h1 [ class "hello" ] [ Html.text "new!" ]
, Html.a [ href "/login" ] [ Html.text "Login" ]
, Html.text "hello"
]```
then you can use
```bash
elm-static-html --filename Main.elm --output index.html
```
which will produce
```html
```## Flags
`elm-static-html -f Main.elm` will print the output to stdout by default
You can create an initial config file through `elm-static-html --init-config`, though it's not needed to work.You can use the config file to generate multiple files through `elm-static-html -c elm-static-html.json`.
The config file looks like this:```js
{
"files": {
"": {
"output": "",
"viewFunction": "view"
},
"",
"viewFunction": "someViewFunc"
}
/* ... */
}
}
```To generate multiple output files from a single elm file, supply an array of outputFile/viewFunction pairs:
```js
{
"files": {
"": [{
"output": "",
"viewFunction": "view"
}, {
"output": "",
"viewFunction": "anotherView"
}]
}
}
```## Notes
An .elm-static-html folder is created in order to generate the correct HTML and JS needed. You can delete it if you want, but it'll make builds a little slower.