Compile HTML files into Elm code!
Installation
git clone https://github.com/avh4/elm-compile-html.gitcd elm-compile-htmlnpm install --global
Use
elm-package install evancz/elm-htmlelm-compile-html MyHtmlFile.html > MyHtmlFile.elm
You can now import MyHtmlFile
as an Elm module:
import MyHtmlFile main = MyHtmlFile.render
Example
MyPanel.html:
Panel title Panel content
Running elm-compile MyPanel.html
yields:
module MyPanel where import Html exposing (Html)import Html.Attributes as Attr render : Htmlrender = Html.node "div" [ Attr.attribute "class" "panel panel-default" ] [ Html.text "\n " , Html.node "div" [ Attr.attribute "class" "panel-heading" ] [ Html.text "\n " , Html.node "h3" [ Attr.attribute "class" "panel-title" ] [ Html.text "Panel title" ] , Html.text "\n " ] , Html.text "\n " , Html.node "div" [ Attr.attribute "class" "panel-body" ] [ Html.text "\n Panel content\n " ] , Html.text "\n" ]
Demos
See examples/Clock/README.md
.
Development
Running tests:
npm test