我正在使用 Heist 模板制作一个简单的 Snap 应用程序。我想将请求 url 打印到页面中。但是,不是运行我的拼接,而是输出只有拼接标签。我觉得我忽略了一些简单的事情,因为我找不到我的应用程序和我找到的教程之间的任何区别。
网站.hs:
{-# LANGUAGE OverloadedStrings #-}
module Site
( app
) where
import Data.Monoid
import Snap.Core
import Snap.Snaplet
import Snap.Snaplet.Heist
import Heist
import Application
import Control.Monad.Trans.Class (lift)
import Data.Text.Encoding (decodeUtf8)
import qualified Text.XmlHtml as X
currentPath :: SnapletISplice App
currentPath = do
requestPath <- lift $ withRequest (return . rqURI)
return [X.TextNode $ decodeUtf8 requestPath]
app :: SnapletInit App App
app = makeSnaplet "andrewlorente" "My wubsite" Nothing $ do
let config = mempty {
hcInterpretedSplices = "currentPath" ## currentPath
}
h <- nestSnaplet "heist" heist $ heistInit' "templates" config
return $ App h
索引.tpl:
<currentPath />
据我所知,访问根路径 / 的渲染输出应该类似于
/
但实际上它是
<currentPath></currentPath>
我束手无策,试图弄清楚为什么我的接头没有运行。