Skip to content

Instantly share code, notes, and snippets.

@newlandsvalley
Created March 7, 2016 19:18
Show Gist options
  • Save newlandsvalley/801b2d6164e4187f9a08 to your computer and use it in GitHub Desktop.
Save newlandsvalley/801b2d6164e4187f9a08 to your computer and use it in GitHub Desktop.
Simple integration of elm with the Play Framework (Scala)
@*
* This template takes a single argument, a String containing a
* message to display.
*@
@(message: String)
@main("The Interactive ABC Tutorial", "abc", "Main") {
<h1>The Interactive ABC Tutorial</h1>
<div id = "abc">
</div>
}
@*
* This template is called from the `index` template. It takes the following parameters:
*
* a Title
* The id of the div tag in which to embed the elm code
* The name of the elm Module (very often this will be Main)
* The HTML content
*@
@(title: String, elmDivId: String, elmModule: String)(content: Html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
<script src="@routes.Assets.versioned("javascripts/abc-player.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
<script type="text/javascript">
var abcDiv = document.getElementById('@elmDivId');
Elm.embed(Elm.@elmModule, abcDiv);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment