on cb359fa help sign in
41 lines 1.0 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE QuasiQuotes #-}
3module Generate.Html
4 ( sandwich
5 )
6 where
9import qualified Data.ByteString.Builder as B
10import Data.Monoid ((<>))
11import qualified Data.Name as Name
12import Text.RawString.QQ (r)
16-- SANDWICH
19sandwich :: Name.Name -> B.Builder -> B.Builder
20sandwich moduleName javascript =
21 let name = Name.toBuilder moduleName in
22 [r|<!DOCTYPE HTML>
23<html>
24<head>
25 <meta charset="UTF-8">
26 <title>|] <> name <> [r|</title>
27</head>
29<body>
30<div id="elm-f0111bc4e658d0f98db96260c16f7e49"></div>
31<script>
32|] <> javascript <> [r|
34var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49") });
35if (document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49"))
37 document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49").innerText = 'This is a headless program, meaning there is nothing to show here.\n\nI started the program anyway though, and you can access it as `app` in the developer console.';
39</script>
40</body>
41</html>|]