on master help sign in
* updated elm-yesod example (URL interpolation)
c6f9c18Vincent Ambo
Examples/elm-yesod/Main.hs+17−14
@@ -36,31 +36,34 @@ mkYesod "ElmTest" [parseRoutes|
36-- generateWidget is called with the result of an Elm QuasiQuoter (which is just a
36-- generateWidget is called with the result of an Elm QuasiQuoter (which is just a
37-- string containing some Elm code, with proper newline escaping)
37-- string containing some Elm code, with proper newline escaping)
38getMouseR :: Handler RepHtml
38getMouseR :: Handler RepHtml
39+getMouseR = do
40+ widget <- elmWidget mousePage
39−getMouseR = defaultLayout $ do
41+ defaultLayout $ do
40− setTitle "Mouse position demo"
42+ setTitle "Mouse position demo"
41− elmWidget mousePage
43+ widget
42
44
43getClockR :: Handler RepHtml
45getClockR :: Handler RepHtml
46+getClockR = do
47+ widget <- elmWidget clockPage
44−getClockR = defaultLayout $ do
48+ defaultLayout $ do
45− setTitle "A clock"
49+ setTitle "A clock"
46− elmWidget clockPage
50+ widget
47
51
48getShapesR :: Handler RepHtml
52getShapesR :: Handler RepHtml
53+getShapesR = do
54+ widget <- elmWidget shapesPage
49−getShapesR = defaultLayout $ do
55+ defaultLayout $ do
50− setTitle "Simple shapes"
56+ setTitle "Simple shapes"
51− elmWidget shapesPage
57+ widget
52
58
53-- URLs are rendered manually and then passed on to the function containing
59-- URLs are rendered manually and then passed on to the function containing
54-- the elm QuasiQuoter.
60-- the elm QuasiQuoter.
55getRootR :: Handler RepHtml
61getRootR :: Handler RepHtml
56getRootR = do
62getRootR = do
57− render <- getUrlRender
63+ widget <- elmWidget $(elmFile "elm_source/index.elm")
58 defaultLayout $ do
64 defaultLayout $ do
59− let mouse = render MouseR
60− clock = render ClockR
61− shapes = render ShapesR
62 setTitle "Welcome!"
65 setTitle "Welcome!"
63− elmWidget $(elmFile "elm_source/index.elm")
66+ widget
64
67
65
68
66-- Our Yesod instance contains the default layout, which inserts the elm-min.js
69-- Our Yesod instance contains the default layout, which inserts the elm-min.js
Examples/elm-yesod/elm_source/index.elm+3−3
@@ -25,9 +25,9 @@ info w = List.map (\f -> f ()) . List.intersperse (\x -> plainText "&nbsp;") . L
25 toText ". Since you are looking at this page it is safe to assume that you already have the example code. "
25 toText ". Since you are looking at this page it is safe to assume that you already have the example code. "
26 , text $ toText "Type-safe URLs are rendered using simple QuasiQuoter variable interpolation."
26 , text $ toText "Type-safe URLs are rendered using simple QuasiQuoter variable interpolation."
27 , section "More examples:"
27 , section "More examples:"
28− , text $ toText "- " ++ link "#{mouse}" (toText "A simple mouse input example")
28+ , text $ toText "- " ++ link "@{MouseR}" (toText "A simple mouse input example")
29− , text $ toText "- " ++ link "#{clock}" (toText "An animated analog clock")
29+ , text $ toText "- " ++ link "@{ClockR}" (toText "An animated analog clock")
30− , text $ toText "- " ++ link "#{shapes}" (toText "Some simple rendered shapes")
30+ , text $ toText "- " ++ link "@{ShapesR}" (toText "Some simple rendered shapes")
31 ]
31 ]
32
32
33body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner
33body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner