on master help sign in
Change the Generate.Html.sandwich

Do a little bit more styling, and show initialization errors on screen if there are any. (Need to do that or you get the "headless program" message, which makes no sense in that context!)

commitaf3bc723fe7f15f7931ca5ad45b5c65606b06501 authorEvan Czaplicki <evancz@users.noreply.github.com> dateSun 24 Mar 2019, 15:45 (8 years ago) parentf106fd0
1 file changed+17−5
compiler/src/Generate/Html.hs+17−5
compiler/src/Generate/Html.hs+17−5
@@ -24,18 +24,30 @@ sandwich moduleName javascript =
2424<head>
2525 <meta charset="UTF-8">
2626 <title>|] <> name <> [r|</title>
27+ <style>body { padding: 0; margin: 0; }</style>
2728</head>
2829
2930<body>
30−<div id="elm-df98db9626"></div>
31+
32+<pre id="elm">
33+This is a headless program, meaning there is nothing to show here.
34+
35+I started the program anyway though!
36+
37+You can access it as `app` in the developer console.
38+</pre>
39+
3140<script>
3241|] <> javascript <> [r|
3342
34−var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm-df98db9626") });
35−if (document.getElementById("elm-df98db9626"))
36−{
37− document.getElementById("elm-df98db9626").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.';
43+try {
44+ var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm") });
45+} catch (e) {
46+ // display initialization errors (e.g. bad flags, infinite recursion)
47+ document.getElementById("elm").innerText = e;
48+ throw e;
3849}
3950</script>
51+
4052</body>
4153</html>|]