0

我在尝试渲染模板时遇到了https://hackage.haskell.org/package/snap-1.0.0.1/docs/Snap-Snaplet-Heist-Interpreted.html#v:render问题。仅当我将以下内容作为模板内容时才会出现此问题:

<!DOCTYPE html>
</html>

而以下内容呈现正常

<html>
</html>

所以它似乎与 HTML doctype 有关。

发生的异常:

*** Exception: 
Initializer threw an exception...
/home/chris/Projects/Haskell/pkgscrape/Snap/snaplets/heist/templates/compareForm.tpl "/home/chris/Projects/Haskell/pkgscrape/Snap/snaplets/heist/templates/compareForm.tpl" (line 21, column 2):
unexpected "/"
CallStack (from HasCallStack):
  error, called at src/Snap/Snaplet/Heist/Internal.hs:74:35 in snap-1.0.0.1-6iNEjVc81Z8CCk3FAMxZ8z:Snap.Snaplet.Heist.Internal

...but before it died it generated the following output:
Initializing myapp @ /
Initializing heist @ /heist


CallStack (from HasCallStack):
  error, called at src/Snap/Snaplet/Internal/Initializer.hs:597:13 in snap-1.0.0.1-6iNEjVc81Z8CCk3FAMxZ8z:Snap.Snaplet.Internal.Initializer
4

1 回答 1

3

您的第一个示例不是有效的 HTML。我想你想要:

<!DOCTYPE html>
<html>
</html>

文档类型与开始<html>标签不同。

浏览器真的很宽容,所以他们会毫无怨言地接受你的版本,但是 Interpreted Heist 会尝试将模板解析为有效的 HTML,所以它会在</html>没有正确开始标记的情况下阻塞结束标记 ( )。

于 2017-01-23T14:51:57.237 回答