将运行时拼接与Snap / Heist应用程序集成

时间:2014-03-26 05:03:14

标签: haskell haskell-snap-framework heist

我正在使用Heist模板组合一个简单的Snap应用程序。我想将请求网址打印到页面中。但是,输出只是具有splice标签,而不是运行我的拼接。我觉得我忽略了一些简单的事情,因为我发现我的应用程序和我发现的教程之间没有任何区别。

Site.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

在index.tpl:

<currentPath />

据我所知,访问根路径/的渲染输出应该类似于

/

但事实上它是

<currentPath></currentPath>

我正试着弄清楚为什么我的拼接没有运行。

1 个答案:

答案 0 :(得分:1)

hnnnnngh

根本不是代码问题。我曾经在某个时候切换到使用cabal沙箱,但是还没有更新我的$ PATH所以我仍在执行一个没有定义拼接的代码的旧版本。

相关问题