我正在 Yesod 进行用户注册过程。该计划是向新注册的用户发送一封电子邮件,以激活他们的帐户。我试图创建一个小部件,其中包含一个返回到接受电子邮件确认代码的路由的 Typed-Url。
---模板.hamlet
<h3>Email Change Confirmation
<p>A new email address has been set for your account with Dropship Center.
$case ecrType
$of New
<p>Please click
<a href=@{UserConfirmationR}/#{code}>here
to confirm.
---用户.hs
import Text.Blaze.Html.Renderer.Text (renderHtml)
postUserR :: Handler Value
postUserR = do
val <- parseJsonBody :: Handler (Result Registration)
case val of
Error e -> return $ object [ "error" .= e ]
Success Registration{..} -> do
...database actions...
let ecrType = New
code = (ecrNewConfirm ecr)
html = renderHtml $ $(widgetFile "ecr-message")
...send confirmation email using "html" as the message body...
不幸的是,我不断收到以下错误。我一直无法弄清楚。
Handler/User.hs:84:46:
Couldn't match type `WidgetT site0 m0'
with `blaze-markup-0.6.0.0:Text.Blaze.Internal.MarkupM'
Expected type: blaze-markup-0.6.0.0:Text.Blaze.Internal.MarkupM ()
Actual type: WidgetT site0 m0 ()
In the return type of a call of `asWidgetT . toWidget'
In a stmt of a 'do' block:
(asWidgetT . toWidget)
((blaze-markup-0.6.0.0:Text.Blaze.Internal.preEscapedText . pack)
"<h3>Email Change Confirmation</h3>\
\<p>A new email address has been set for your account with Dropship Center.")
In a stmt of a 'do' block:
do { (asWidgetT . toWidget)
((blaze-markup-0.6.0.0:Text.Blaze.Internal.preEscapedText . pack)
"<h3>Email Change Confirmation</h3>\
\<p>A new email address has been set for your account with Dropship Center.");
case ecrType of {
New -> do { ... }
Old -> do { ... } };
(asWidgetT . toWidget)
((blaze-markup-0.6.0.0:Text.Blaze.Internal.preEscapedText . pack)
"</p>") }
是否有一些将 Widget 转换为 Html 类型的中间阶段?