Yesod:如何构建参数化路线

时间:2011-09-18 01:46:42

标签: haskell yesod hamlet

我尝试在运行时在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模板中的路径。

1 个答案:

答案 0 :(得分:1)

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

buildFeedRow :: Item [Attribute Text] -> GWidget YourFoundation YourFoundation ()