【问题标题】:How to avoid whitespace after a tag (link) in Hamlet templates?如何避免哈姆雷特模板中标签(链接)后的空格?
【发布时间】:2016-03-31 09:01:21
【问题描述】:

我无法找到一种方法来呈现链接,然后立即使用逗号或句号 它,链接和标点符号之间没有空格。这是我的初始 尝试:

<p>
  You can find more information #
  <a href="@{SomeRouteR}">here
  \.

<p>
  You can find more information #
  <a href="@{SomeRouteR}">here
  .

这会在单词“here”和“.”之间插入空格。

另一种选择是:

<p>
  You can find more information #
  <a href="@{SomeRouteR}">here</a>.

这看起来很成功,但 HTML 格式错误:

<p>You can find more information <a href="…">here</a>.</a></p>

有没有办法避免链接和标点符号/其他之间的空格 元素?

【问题讨论】:

    标签: haskell yesod hamlet


    【解决方案1】:

    一些选项:

    1. $newline never 添加到文件顶部,以更改在标签后添加换行符的默认设置。
    2. 紧跟单词here 后添加# 以禁用该标签的自动换行符。
    3. 像您尝试的那样使用显式结束标记。但要完成这项工作,您需要以反斜杠开始该行,以告诉 Hamlet 不要为您自动关闭标签:\&lt;a href=#&gt;here&lt;/a&gt;.

    【讨论】:

    • 这是最好的框架!恭喜所有开发 Yesod 的人!
    猜你喜欢
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    相关资源
    最近更新 更多