@@ -19,43 +19,35 @@ import qualified Elm.Name as N
1919
2020sandwich :: N.Name -> B.Builder -> B.Builder
2121sandwich moduleName javascript =
22− header <> javascript <> footer (N.toBuilder moduleName)
23−
24−
25−header :: B.Builder
26−header = [r|
27−<!DOCTYPE HTML>
22+ let name = N.toBuilder moduleName in
23+ [r|<!DOCTYPE HTML>
2824<html>
2925<head>
3026 <meta charset="UTF-8">
27+ <title>|] <> name <> [r|</title>
3128</head>
3229
3330<body>
3431<div id="embed"></div>
3532<script>
36−|]
37−
38−
39−footer :: B.Builder -> B.Builder
40−footer name =
41− "</script>\n\
42− \<script>\n\
43− \// It is too complicated to figure out which kind of Program you created\n\
44− \// based on only the code. So here we check for different possibilities.\n\
45− \//\n\
46− \// When you embed compiled Elm into HTML yourself, you should not copy/paste\n\
47− \// from here. Do just the part that makes sense for your application!\n\
48− \//\n\
49− \var app =\n\
50− \ Elm." <> name <> ".fullscreen\n\
51− \ ? Elm." <> name <> ".fullscreen()\n\
52− \ :\n\
53− \ Elm." <> name <> ".embed\n\
54− \ ? Elm." <> name <> ".embed(document.getElementById('embed'))\n\
55− \ :\n\
56− \ Elm." <> name <> ".worker\n\
57− \ ? (document.getElementById('embed').innerText = 'This is a headless program, meaning there is nothing to show here. I started the program anyway though, and you can access it as `app` in the developer console.', Elm." <> name <> ".worker())\n\
58− \ : (document.getElementById('embed').innerText = 'I cannot figure out what kind of program this is supposed to be. Perhaps someone on Slack can help?', undefined);\n\
59− \</script>\n\
60− \</body>\n\
61− \</html>"
33+|] <> javascript <> [r|
34+
35+// It is too complicated to figure out which kind of Program you created
36+// based on only the code. So here we check for different possibilities.
37+//
38+// When you embed compiled Elm into HTML yourself, you should not copy/paste
39+// from here. Do just the part that makes sense for your application!
40+//
41+var app =
42+ Elm.|] <> name <> [r|.fullscreen
43+ ? Elm.|] <> name <> [r|.fullscreen()
44+ :
45+ Elm.|] <> name <> [r|.embed
46+ ? Elm.|] <> name <> [r|.embed(document.getElementById('embed'))
47+ :
48+ Elm.|] <> name <> [r|.worker
49+ ? (document.getElementById('embed').innerText = 'This is a headless program, meaning there is nothing to show here. I started the program anyway though, and you can access it as `app` in the developer console.', Elm.|] <> name <> [r|.worker())
50+ : (document.getElementById('embed').innerText = 'I cannot figure out what kind of program this is supposed to be. Perhaps someone on Slack can help?', undefined);
51+</script>
52+</body>
53+</html>|]