【问题标题】:Nested anchor tag within h3 in scalatagsscalatags中h3内的嵌套锚标记
【发布时间】:2016-04-08 14:01:08
【问题描述】:

我正在尝试从 scalatags 生成以下 HTML:

<h3>There were orders found in <a href="#somewhere">somewhere </a> and <a href="#somewhereelse">somewhere else </a> </h3>

到目前为止,我在 scalatags 中使用以下内容的尝试没有奏效:

h3("There were orders found in" + a(href:="#somewhere")("somewhere") + "and" + a(href:="#somewhereelse")("somewhere else"))

【问题讨论】:

  • 您遇到什么错误?你为什么使用柯里化?

标签: html scala scalatags


【解决方案1】:
h3("There were orders found in ", a(href:="#somewhere", "somewhere"), 
    " and ", a(href:="#somewhereelse", "somewhere else"))

这就是 XML 中的结构:

- <h3>
  - TEXT
  - <a>
    - TEXT
  - TEXT
  - <a>
    - TEXT

如果您尝试并坚持以与 XML 中的结构相同的方式编写 scalatags 代码,那么应该可以。还要记住,在 scalatags 中你穿插了属性 (... := ...) 和孩子; scalatags 找出哪个是哪个。

【讨论】:

  • 这对我来说是最有意义的。像 XML 一样思考它有很大帮助。
猜你喜欢
  • 2010-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-12
  • 1970-01-01
  • 2011-07-10
  • 2011-01-13
  • 1970-01-01
相关资源
最近更新 更多