2

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.

Steve Severance
  • 6,611
  • 1
  • 33
  • 44
  • 2
    I don't see anything wrong with this bit of code, I'm guessing there's something else at play here. Maybe try adding some type signatures, or include some more of the surrounding code in your snippet. – Michael Snoyman Sep 18 '11 at 03:01

1 Answers1

1

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 ()
hammar
  • 138,522
  • 17
  • 304
  • 385