0
import Data.String.Conversions
import Data.Maybe (isJust)
import qualified Heist
import qualified Heist.Interpreted as I
import qualified Heist.Compiled as HeistCom
import Heist.Internal.Types
import qualified Text.XmlHtml as X
import Data.List (sortBy)
import Data.Map.Syntax
import Data.ByteString.Builder (toLazyByteString)
renderTemplate :: String -> (HeistState IO -> HeistState IO) -> ActionM()
renderTemplate fileName hsBinding = do
let emptyI = return() :: MapSyntax Text (I.Splice IO)
let emptyC = return() :: MapSyntax Text (HeistCom.Splice IO)
let emptyA = return() :: MapSyntax Text (AttrSplice IO)
let spliceConfig = SpliceConfig emptyI emptyI emptyC emptyA [] (\_ -> False):: SpliceConfig IO
heist <- lift $ Heist.initHeist (HeistConfig spliceConfig "" True)
case heist of
Right heist' -> do
rendered <- lift $ I.renderTemplate (hsBinding heist') $ convertString fileName
case (rendered) of
Just (builder, _) -> do
lift $ print $ toLazyByteString builder
Nothing -> error "heist error"
Left a -> error . convertString $ show a
我打電話的功能是這樣的:渲染搶劫模板沒有返回
renderTemplate "templates/compareForm" $ I.bindSplice "test" $ I.textSplice "abcxyz"
我猜它是與配置做。我沒有徹底想通過上述配置。
不幸的是,以上只是產生一個「heist錯誤」(第二行)的錯誤。所以我的問題是爲什麼?我的下一步將是調查Heist.Interpreted.renderTemplate
函數。
是否'renderTemplate'工作,沒有拼接一個非常簡單的模板(甚至只是'')和'id'你'(HeistState IO - > HeistState IO) '功能? – Libby
與上述建議相同的結果。 –