我正在尝试将网页的标题设置为包含当前年份的字符串,如下所示:
getCurrentYear :: IO String
getCurrentYear = do
now <- getCurrentTime
let today = utctDay now
let (year, _, _) = toGregorian today
return $ show year
title :: IO Html
title = do
y <- getCurrentYear
return $ toHtml $ "Registration " ++ y
getRootR :: Handler RepHtml
getRootR = do
(widget, enctype) <- generateFormPost personForm -- not important for the problem at hand, comes from the example in the yesod book
defaultLayout $ do
setTitle title -- this …Run Code Online (Sandbox Code Playgroud)