Skip to content

Instantly share code, notes, and snippets.

@shamrin
Last active April 7, 2017 15:07
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save shamrin/06599db083cf98e7eef2 to your computer and use it in GitHub Desktop.
Save shamrin/06599db083cf98e7eef2 to your computer and use it in GitHub Desktop.
Multiple Elm main modules
elm-package install --yes evancz/elm-html
elm-make First.elm Second.elm --output bundle.js --yes
module First where
import Html exposing (span, text)
main = span [ ] [text "Hello First!"]
<html>
<body>
<div id="first"></div>
<div id="second"></div>
<script src="bundle.js"></script>
<script>
var first = document.getElementById('first');
Elm.embed(Elm.First, first);
var second = document.getElementById('second');
Elm.embed(Elm.Second, second);
</script>
</body>
</html>
module Second where
import Html exposing (span, text)
main = span [ ] [text "Hello Second!"]
@DanielsLuz
Copy link

For future readers
Hi, I came across this gist from this discussion.
Please consider updating the Elm.embed syntax for the 0.17 version as mentioned here.
It should go from
Elm.embed(Elm.MyApp, someElement)
to
Elm.MyApp.embed(someElement)

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment