* updated elm-yesod Example to use variable interpolation for URLs

This commit is contained in:
Vincent Ambo 2012-05-29 02:58:37 +02:00
parent fd1b410ea4
commit 6b2b4180ad
2 changed files with 14 additions and 7 deletions

View File

@ -13,7 +13,7 @@ data ElmTest = ElmTest
-- embedding an external elm file (note: no spaces!)
mousePage = [elmFile|elm_source/mouse.elm|]
rootPage = [elmFile|elm_source/index.elm|]
rootPage mouse clock shapes = [elmFile|elm_source/index.elm|]
clockPage = [elmFile|elm_source/clock.elm|]
@ -55,10 +55,17 @@ getShapesR = defaultLayout $ do
setTitle "Simple shapes"
generateWidget shapesPage
-- URLs are rendered manually and then passed on to the function containing
-- the elm QuasiQuoter.
getRootR :: Handler RepHtml
getRootR = defaultLayout $ do
setTitle "Welcome!"
generateWidget rootPage
getRootR = do
render <- getUrlRender
defaultLayout $ do
let mouse = render MouseR
clock = render ClockR
shapes = render ShapesR
setTitle "Welcome!"
generateWidget $ rootPage mouse clock shapes
-- Our Yesod instance contains the default layout, which inserts the elm-min.js

View File

@ -26,9 +26,9 @@ info w = List.map (\f -> f ()) . List.intersperse (\x -> plainText "&nbsp;") . L
, text $ toText "Rendering Yesod's type-safe URLs is not yet possible, but will be implemented as the currently " ++
toText "very simple QuasiQuoter is extended."
, section "More examples:"
, text $ toText "- " ++ link "/mouse" (toText "A simple mouse input example")
, text $ toText "- " ++ link "/clock" (toText "An animated analog clock")
, text $ toText "- " ++ link "/shapes" (toText "Some simple rendered shapes")
, text $ toText "- " ++ link ^{mouse} (toText "A simple mouse input example")
, text $ toText "- " ++ link ^{clock} (toText "An animated analog clock")
, text $ toText "- " ++ link ^{shapes} (toText "Some simple rendered shapes")
]
body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner