【问题标题】:Why isn't Velocity displaying <div>'s that should be displayed as "display: flex;" correctly?为什么 Velocity 不显示应该显示为“display: flex;”的 <div>正确吗?
【发布时间】:2020-04-06 13:53:52
【问题描述】:

我对 Apache Velocity 引擎有疑问。

我的模板中有一段 html:

<p>
    <span><b>${contextString}: ${context.contextTitle}</b></span>
    <div style="display: flex;">
        <div>${published}</div>
        <div>${context.published}</div>
        <div>${noWorkflow}</div>
        <div>${context.reviewed}</div>
    </div>
</p>

但是当我测试这个模板时,Velocity 似乎以某种方式将这些 DIV 转换为常规的 display: block; 或完全忽略 display: flex;,以新行显示所有项目。

为什么 Velocity 显示不正确?有没有办法解决这个问题?

【问题讨论】:

    标签: java html templates velocity


    【解决方案1】:

    这不是 Velocity 问题:在 $references 和 #directives 之外,Velocity 不会解释它正在格式化的文本,它是 HTML 还是其他。

    您的代码中至少有一个 HTML 问题可能导致此问题:&lt;p&gt; 标签不能包含&lt;div&gt; 标签,因此&lt;p&gt; 在遇到第一个&lt;div&gt; 时会关闭。见this related answer。

    【讨论】:

      猜你喜欢
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      相关资源
      最近更新 更多