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

时间:2017-01-23 14:20:18

标签: haskell haskell-snap-framework heist

我在尝试渲染模板时遇到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

1 个答案:

答案 0 :(得分:3)

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

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

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

浏览器非常宽松,因此他们会毫无怨言地接受您的版本,但解释性Heist会尝试将模板解析为有效的HTML,因此它会在没有正确的开始标记的情况下在结束标记(</html>)上窒息。