英文:
Why isn't Velocity displaying <div>'s that should be displayed as "display: flex;" correctly?
问题
我在使用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会显示出现这种错误?有没有方法可以修复这个问题?
英文:
I have problem with Apache Velocity engine.
I have a piece of html in my template:
<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>
But when I test this template, Velocity seems to somehow convert those DIVs into regular display: block;
or is ignoring display: flex;
completely, displaying all items in new lines.
Why is Velocity displaying this incorrectly? Is there any way to fix this?
答案1
得分: 0
这并不是一个 Velocity 的问题:在 $references
和 #directives
之外,Velocity 不会解释要格式化的文本,无论是 HTML 还是其他内容。
在你的代码中至少存在一个可能引起问题的 HTML 问题:<p>
标签不能包含 <div>
标签,所以当它遇到第一个 <div>
标签时,<p>
标签会被关闭。请参考这个相关答案。
英文:
This is not a Velocity problem: outside of $references
and #directives
, Velocity does not interpret the text it is formatting, would it be HTML or else.
There is at least one HTML problem in your code that may cause this: <p>
tags cannot contain <div>
tags, so the <p>
is closed when it encounters the first <div>
. See this related answer.
专注分享java语言的经验与见解,让所有开发者获益!
评论