heist

Rendering a heist template returns nothing

妖精的绣舞 提交于 2019-12-12 01:14:55
问题 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)

Passing data directly into templates in compiled Heist (Haskell)?

二次信任 提交于 2019-12-11 06:57:14
问题 I use compiled Heist. My splices only do run-time work (no load-time work). I have a template.tpl like this: <html> <head> <title><titleSplice/></title> </head> <body> <bodySplice/> </body> </html> This is how I do things: Within the Snap action for a /:param route, I use renderTemplate heistState "template" to obtain a MyHeistRuntimeMonad Builder . I can pass the :param value to my splice by putting it into my runtime monad via ReaderT: type MyHeistRuntimeMonad = ReaderT String IO . (Where

Digestive Functors with a variable number of subforms (Snap/Heist)

落花浮王杯 提交于 2019-12-08 15:41:03
问题 I'm working on porting a site from PHP to Snap w/ Heist. I've ported some of the simpler forms to using Digestive Functors successfully, but now I have to do the tricky ones that require the use of subforms. This application manages producing flyers for retail stores, so one of the tasks that need to be done is adding an ad size and defining its physical dimensions on the printed flyer. Sizes will vary depending on the type of page (configurable by the flyer owner) and its orientation (which

Snap: compiled splices code example

巧了我就是萌 提交于 2019-12-06 05:57:39
问题 I think I did asked a similar question some time ago but it was not answered due to unstable API. So I was waiting for the 0.13 to pass by. I am not sure if it is correct to bring up a similar question...? What is the alternative to interpreted runChildrenWith(Text) and mapSplices in the compiled splices world? (this combination seems to be the most common) I would really appreciate some code examples if possible. If I understand correctly, we get together all the application splices and then

Snap: compiled splices code example

こ雲淡風輕ζ 提交于 2019-12-04 11:26:26
I think I did asked a similar question some time ago but it was not answered due to unstable API. So I was waiting for the 0.13 to pass by. I am not sure if it is correct to bring up a similar question...? What is the alternative to interpreted runChildrenWith(Text) and mapSplices in the compiled splices world? (this combination seems to be the most common) I would really appreciate some code examples if possible. If I understand correctly, we get together all the application splices and then add them to the heistInit . Can anyone show how to do it please? Does the splice binding tag has to be

How to show utf8 text with snap and heist?

半城伤御伤魂 提交于 2019-11-30 09:58:50
问题 I have used writeBS writeText from Snap and renderTemplate from heist but none of them seems to support unicode. site :: Snap () site = do ifTop (writeBS "你好世界") <|> route [("test", testSnap)] testSnap :: Snap () testSnap = do fromJust $ C.renderTemplate hs "test" -- test.tpl 你好世界 I expected it to output "你好世界" for the / or /test route, but in fact its output is just some messy code. 回答1: The problem here is not with writeBS or writeText. It's with the conversion used by the OverloadedStrings