on master help sign in
* documentation for Language.Elm.Yesod
commit4fa6d8051f2d8dbde0c0e6a610168c638f226468 authorVincent Ambo <v.ambo@me.com> dateMon 28 May 2012, 18:13 (14 years ago) parentc08f775
1 file changed+20−1
elm-yesod/Language/Elm/Yesod.hs+20−1
elm-yesod/Language/Elm/Yesod.hs+20−1
@@ -1,5 +1,20 @@
11{-# LANGUAGE QuasiQuotes #-}
2+{- | This module provides a function for compiling Elm source code into a Yesod widget.
3+ In order to use this with your Yesod app, you need to define a defaultLayout like
4+ function that embeds the elm-min.js file /in the <head> tag/.
25
6+ For example, you could modify your Yesod instance as follows:
7+
8+ > instance Yesod App where
9+ > jsLoader _ = BottomOfHeadBlocking -- moves JS to the <head> tag
10+ > defaultLayout widget = do
11+ > pc <- widgetToPageContent $ do
12+ > addScriptRemote $ "http://somecdn.org/link/to/elm-min.js"
13+ > ...
14+ > ...
15+
16+ A full example implementation is provided in the examples folder of the Elm github repository.
17+-}
318module Language.Elm.Yesod (generateWidget) where
419
520import Text.Blaze (preEscapedToMarkup)
@@ -21,7 +36,11 @@ a:link, a:visited, a:active { text-decoration: none}
2136a:hover {text-decoration: underline; color: #ff8f12;}
2237|]
2338
24−generateWidget :: String -> GWidget sub master ()
39+-- |generateWidget takes some Elm code in String format and produces a widget. Usage example:
40+--
41+-- > generateWidget [elmFile|elm-source/somePage.elm|]
42+generateWidget :: String -- ^ The Elm source code
43+ -> GWidget sub master ()
2544generateWidget source =
2645 let expr = initialize source
2746 js = compileToJS expr