【问题标题】:Integrating a runtime splice with a Snap/Heist app将运行时拼接与 Snap/Heist 应用程序集成
【发布时间】:2014-03-26 22:08:10
【问题描述】:

我正在使用 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

index.tpl:

<currentPath />

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

/

其实是这样的

<currentPath></currentPath>

我束手无策,试图弄清楚为什么我的接头没有运行。

【问题讨论】:

    标签: haskell haskell-snap-framework heist


    【解决方案1】:

    呵呵

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

    【讨论】:

    • 您还需要在 HeistConfig 中包含您的模板。
    猜你喜欢
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 2012-04-15
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多