[英]How do you update code using loadTemplates for the new Heist API?
此代码在0.10.0更改之前与Heist一起使用
main = do
Right ts <- loadTemplates "templates" $
bindSplices mySplices defaultHeistState
etc..
现在我得到了错误
testdb.hs:59:33: Not in scope: `defaultHeistState'
我知道loadTemplates的类型签名已更改为
loadTemplates :: FilePath -> EitherT [String] IO TemplateRepoSource
但是我在弄清楚如何改编旧代码以使其正常工作时遇到了麻烦。
好吧,我可以使用它,但是我愿意接受更优雅的方法
load baseDir splices = do
tmap <- runEitherT $ do
templates <- loadTemplates baseDir
let hc = HeistConfig mySplices [] [] [] templates
initHeist hc
either (error . concat) return tmap
main = do
ts <- load "templates" $ bindSplices mySplices
renderWithArgs [("test", T.pack "hello world")] ts "index" >>=
B.putStr . maybe "Page not found" (toByteString . fst)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.