on master help sign in
* updated elm-yesod example (URL interpolation)
commitc6f9c1804c525c93c4695dd61f96182a01ef192b authorVincent Ambo <v.ambo@me.com> dateWed 30 May 2012, 21:33 (14 years ago) parentb64f12f
2 files changed+20−17
Examples/elm-yesod/Main.hs+17−14 Examples/elm-yesod/elm_source/index.elm+3−3
Examples/elm-yesod/Main.hs+17−14
@@ -36,31 +36,34 @@ mkYesod "ElmTest" [parseRoutes|
3636-- generateWidget is called with the result of an Elm QuasiQuoter (which is just a
3737-- string containing some Elm code, with proper newline escaping)
3838getMouseR :: Handler RepHtml
39−getMouseR = defaultLayout $ do
40− setTitle "Mouse position demo"
41− elmWidget mousePage
39+getMouseR = do
40+ widget <- elmWidget mousePage
41+ defaultLayout $ do
42+ setTitle "Mouse position demo"
43+ widget
4244
4345getClockR :: Handler RepHtml
44−getClockR = defaultLayout $ do
45− setTitle "A clock"
46− elmWidget clockPage
46+getClockR = do
47+ widget <- elmWidget clockPage
48+ defaultLayout $ do
49+ setTitle "A clock"
50+ widget
4751
4852getShapesR :: Handler RepHtml
49−getShapesR = defaultLayout $ do
50− setTitle "Simple shapes"
51− elmWidget shapesPage
53+getShapesR = do
54+ widget <- elmWidget shapesPage
55+ defaultLayout $ do
56+ setTitle "Simple shapes"
57+ widget
5258
5359-- URLs are rendered manually and then passed on to the function containing
5460-- the elm QuasiQuoter.
5561getRootR :: Handler RepHtml
5662getRootR = do
57− render <- getUrlRender
63+ widget <- elmWidget $(elmFile "elm_source/index.elm")
5864 defaultLayout $ do
59− let mouse = render MouseR
60− clock = render ClockR
61− shapes = render ShapesR
6265 setTitle "Welcome!"
63− elmWidget $(elmFile "elm_source/index.elm")
66+ widget
6467
6568
6669-- 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
2525 toText ". Since you are looking at this page it is safe to assume that you already have the example code. "
2626 , text $ toText "Type-safe URLs are rendered using simple QuasiQuoter variable interpolation."
2727 , section "More examples:"
28− , text $ toText "- " ++ link "#{mouse}" (toText "A simple mouse input example")
29− , text $ toText "- " ++ link "#{clock}" (toText "An animated analog clock")
30− , text $ toText "- " ++ link "#{shapes}" (toText "Some simple rendered shapes")
28+ , text $ toText "- " ++ link "@{MouseR}" (toText "A simple mouse input example")
29+ , text $ toText "- " ++ link "@{ClockR}" (toText "An animated analog clock")
30+ , text $ toText "- " ++ link "@{ShapesR}" (toText "Some simple rendered shapes")
3131 ]
3232
3333body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner