on master help sign in
Generate HTML that accounts for Elm.Main.init()
9e9f4ffEvan Czaplicki
builder/src/Generate/Html.hs+6−17
@@ -28,26 +28,15 @@ sandwich moduleName javascript =
28</head>
28</head>
29
29
30<body>
30<body>
31−<div id="embed"></div>
31+<div id="elm-f0111bc4e658d0f98db96260c16f7e49"></div>
32<script>
32<script>
33|] <> javascript <> [r|
33|] <> javascript <> [r|
34
34
35−// It is too complicated to figure out which kind of Program you created
35+var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49") });
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'))
36+if (document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49"))
47− :
37+{
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())
38+ 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.';
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);
39+}
51</script>
40</script>
52</body>
41</body>
53</html>|]
42</html>|]