on master help sign in
* updated elm-yesod Example to use variable interpolation for URLs
6b2b418Vincent Ambo
Examples/elm-yesod/Main.hs+11−4
@@ -13,7 +13,7 @@ data ElmTest = ElmTest
13-- embedding an external elm file (note: no spaces!)
13-- embedding an external elm file (note: no spaces!)
14mousePage = [elmFile|elm_source/mouse.elm|]
14mousePage = [elmFile|elm_source/mouse.elm|]
15
15
16−rootPage = [elmFile|elm_source/index.elm|]
16+rootPage mouse clock shapes = [elmFile|elm_source/index.elm|]
17
17
18clockPage = [elmFile|elm_source/clock.elm|]
18clockPage = [elmFile|elm_source/clock.elm|]
19
19
@@ -55,10 +55,17 @@ getShapesR = defaultLayout $ do
55 setTitle "Simple shapes"
55 setTitle "Simple shapes"
56 generateWidget shapesPage
56 generateWidget shapesPage
57
57
58+-- URLs are rendered manually and then passed on to the function containing
59+-- the elm QuasiQuoter.
58getRootR :: Handler RepHtml
60getRootR :: Handler RepHtml
61+getRootR = do
62+ render <- getUrlRender
59−getRootR = defaultLayout $ do
63+ defaultLayout $ do
64+ let mouse = render MouseR
65+ clock = render ClockR
66+ shapes = render ShapesR
60− setTitle "Welcome!"
67+ setTitle "Welcome!"
61− generateWidget rootPage
68+ generateWidget $ rootPage mouse clock shapes
62
69
63
70
64-- Our Yesod instance contains the default layout, which inserts the elm-min.js
71-- 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
26 , text $ toText "Rendering Yesod's type-safe URLs is not yet possible, but will be implemented as the currently " ++
26 , text $ toText "Rendering Yesod's type-safe URLs is not yet possible, but will be implemented as the currently " ++
27 toText "very simple QuasiQuoter is extended."
27 toText "very simple QuasiQuoter is extended."
28 , section "More examples:"
28 , section "More examples:"
29− , text $ toText "- " ++ link "/mouse" (toText "A simple mouse input example")
29+ , text $ toText "- " ++ link ^{mouse} (toText "A simple mouse input example")
30− , text $ toText "- " ++ link "/clock" (toText "An animated analog clock")
30+ , text $ toText "- " ++ link ^{clock} (toText "An animated analog clock")
31− , text $ toText "- " ++ link "/shapes" (toText "Some simple rendered shapes")
31+ , text $ toText "- " ++ link ^{shapes} (toText "Some simple rendered shapes")
32 ]
32 ]
33
33
34body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner
34body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner