2

我试图在运行时在 hamlet 模板内将参数传递给路由。

  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 |]

它因类型错误而失败。

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'

我的问题是如何将参数传递给 hamlet 模板中的路由。

4

1 回答 1

1

我认为您的小部件的类型签名可能过于通用。由于您使用的是路线,因此它现在取决于您的基础类型,因此它应该具有类型

buildFeedRow :: Item [Attribute Text] -> GWidget YourFoundation YourFoundation ()
于 2011-09-18T08:07:01.797 回答