on master help sign in
* updated elm-yesod Example to use variable interpolation for URLs
commit6b2b4180ad18d5cfedfd5c244500ecb565208c62 authorVincent Ambo <v.ambo@me.com> dateTue 29 May 2012, 02:58 (14 years ago) parentfd1b410
2 files changed+14−7
Examples/elm-yesod/Main.hs+11−4 Examples/elm-yesod/elm_source/index.elm+3−3
Examples/elm-yesod/Main.hs+11−4
@@ -13,7 +13,7 @@ data ElmTest = ElmTest
1313-- embedding an external elm file (note: no spaces!)
1414mousePage = [elmFile|elm_source/mouse.elm|]
1515
16−rootPage = [elmFile|elm_source/index.elm|]
16+rootPage mouse clock shapes = [elmFile|elm_source/index.elm|]
1717
1818clockPage = [elmFile|elm_source/clock.elm|]
1919
@@ -55,10 +55,17 @@ getShapesR = defaultLayout $ do
5555 setTitle "Simple shapes"
5656 generateWidget shapesPage
5757
58+-- URLs are rendered manually and then passed on to the function containing
59+-- the elm QuasiQuoter.
5860getRootR :: Handler RepHtml
59−getRootR = defaultLayout $ do
60− setTitle "Welcome!"
61− generateWidget rootPage
61+getRootR = do
62+ render <- getUrlRender
63+ defaultLayout $ do
64+ let mouse = render MouseR
65+ clock = render ClockR
66+ shapes = render ShapesR
67+ setTitle "Welcome!"
68+ generateWidget $ rootPage mouse clock shapes
6269
6370
6471-- Our Yesod instance contains the default layout, which inserts the elm-min.js
Examples/elm-yesod/elm_source/index.elm+3−3
@@ -26,9 +26,9 @@ info w = List.map (\f -> f ()) . List.intersperse (\x -> plainText "&nbsp;") . L
2626 , text $ toText "Rendering Yesod's type-safe URLs is not yet possible, but will be implemented as the currently " ++
2727 toText "very simple QuasiQuoter is extended."
2828 , section "More examples:"
29− , text $ toText "- " ++ link "/mouse" (toText "A simple mouse input example")
30− , text $ toText "- " ++ link "/clock" (toText "An animated analog clock")
31− , text $ toText "- " ++ link "/shapes" (toText "Some simple rendered shapes")
29+ , text $ toText "- " ++ link ^{mouse} (toText "A simple mouse input example")
30+ , text $ toText "- " ++ link ^{clock} (toText "An animated analog clock")
31+ , text $ toText "- " ++ link ^{shapes} (toText "Some simple rendered shapes")
3232 ]
3333
3434body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner