elm-yesod-0.1: The Elm language Yesod compatibility module.

Safe HaskellSafe-Infered

Language.Elm.Yesod

Description

This module provides a function for compiling Elm source code into a Yesod widget. In order to use this with your Yesod app, you need to define a defaultLayout like function that embeds the elm-min.js file in the <head> tag.

For example, you could modify your Yesod instance as follows:

 instance Yesod App where
    jsLoader _ = BottomOfHeadBlocking -- moves JS to the <head> tag
    defaultLayout widget = do
        pc <- widgetToPageContent $ do
            addScriptRemote $ "http://somecdn.org/link/to/elm-min.js"
            ...
        ...

A full example implementation is provided in the examples folder of the Elm github repository.

Synopsis

Documentation

elmWidgetSource

Arguments

:: ElmUrl (Route master)

Elm source code

-> GHandler sub master (GWidget sub master ()) 

elmWidget returns a Yesod widget from some Elm source code with URL interpolation.

type ElmUrl url = (url -> [(Text, Text)] -> Text) -> ElmSource

Return type of template-reading functions.