HTML 使用 Snap / Heist 模板呈现的文档类型

HTML doctype rendered with Snap / Heist template

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

<!DOCTYPE html>
</html>

而以下内容呈现良好

<html>
</html>

所以这似乎与 HTML 文档类型有关。

发生的异常:

*** 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

您的第一个示例无效 [​​=19=]。我想你想要:

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

doctype 与开始 <html> 标签不同。

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