【问题标题】:HTML doctype rendered with Snap / Heist template使用 Snap / Heist 模板呈现的 HTML 文档类型
【发布时间】:2017-01-23 22:51:57
【问题描述】:

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

【问题讨论】:

    标签: haskell haskell-snap-framework heist


    【解决方案1】:

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

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

    文档类型与打开的&lt;html&gt; 标记不同。

    浏览器真的很宽容,所以他们会毫无怨言地接受您的版本,但是 Interpreted Heist 会尝试将模板解析为有效的 HTML,因此它会在没有正确开始标签的情况下首先卡住结束标签 (&lt;/html&gt;)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-13
      • 2014-04-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多