Special characters when loading template in Heist

6 views
Skip to first unread message

sal

unread,
Mar 10, 2016, 9:39:29 PM3/10/16
to Snap Framework
I have a toy code to load a simple template with "<foo>" tag, and replace its content using getLine capture. When I print it out using Builder -> ByteString conversion, I see "&#10;" in some places. Are these special characters added by Heist? It seems so to me. Here is the code (without import statements):

-- show
runtime
:: RuntimeSplice IO T.Text
runtime
= liftIO $ do
   
Prelude.putStrLn "Write something:"
    T
.pack <$> getLine


splice
:: Splice IO
splice
= return $ yieldRuntimeText $ runtime
-- /show


heistConfig
:: HeistConfig IO
heistConfig
= emptyHeistConfig &
 
(hcNamespace .~ "") &
 
(hcCompiledSplices .~ ("foo" ## splice)) &
 
(hcTemplateLocations .~ [loadTemplates "templates"])


main
= do
    heistState
<- either (error "init error") id <$>
         
(runEitherT $ initHeist heistConfig)
    builder
<- maybe (error "builder error") fst $
         renderTemplate heistState
"simple"
   
Data.ByteString.Char8.putStrLn $ toByteString builder

This is the output (putStrLn from main above is the last line):

*Main> main
Write something:
abc
<body>&#10;    abc&#10;</body>&#10;

This is actual template that is being loaded:

<body>
   
<foo>
       Some text here
   
</foo>
</body>

Is there something wrong about my handling of the template that is causing insertion of "&#10;" in the template at run-time? I tried to do some research to see if "&#10;" has any special meaning but found nothing. So, will very much appreciate help with resolving this.



Thanks.

MightyByte

unread,
Mar 10, 2016, 9:46:17 PM3/10/16
to snap_fr...@googlegroups.com
We are aware of this behavior. The "&#10;" is an escaped linefeed
character. There is an outstanding issue for it on github here with
more details:

https://github.com/snapframework/heist/issues/8

Unfortunately the fix is a fair amount of work and since it doesn't
cause any actual problems in practice we've never gotten around to it.
I would love it if someone took the time to fix it.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Snap Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to snap_framewor...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

sal

unread,
Mar 10, 2016, 10:41:53 PM3/10/16
to Snap Framework
Got it now. Thanks for response. This is not a big deal since it seems to be part of XML spec from what is stated in the bug description. I just wanted to know what is going on here. It was so mysterious (and un-googlable!) until you explained it.
Reply all
Reply to author
Forward
0 new messages