Yesod: How to build parameterized routes
Вопрос
I am try to pass a parameter to a route at runtime inside a hamlet template.
buildFeedRow :: Item [Attribute Text] -> GWidget a a ()
buildFeedRow item = do
let f = unpackItem item
u :: Text = url f
[whamlet|
<tr>
<td>
<a href="#{url f}">#{url f}
<td>#{nextCrawlTime f}
<td>#{crawlDelay f}
<td>
<a href="@{DeleteFeedR u}">Delete
<td>Edit |]
It fails with a type error.
Couldn't match type `Route a' with `ConsoleRoute'
Expected type: ConsoleRoute -> [(Text, Text)] -> Text
Actual type: Route a -> [(Text, Text)] -> Text
Expected type: GHandler
a a (ConsoleRoute -> [(Text, Text)] -> Text)
Actual type: GGHandler
a
a
(Data.Enumerator.Iteratee Data.ByteString.Internal.ByteString IO)
(Route a -> [(Text, Text)] -> Text)
In the first argument of `lift', namely `getUrlRenderParams'
In the first argument of `(>>=)', namely `lift getUrlRenderParams'
My question is how do you pass parameters to routes in a hamlet template.
Решение
I think the the type signature of your widget might be too generic. Since you're using a route, it now depends on your foundation type so it should have the type
buildFeedRow :: Item [Attribute Text] -> GWidget YourFoundation YourFoundation ()
Не связан с StackOverflow