Bugzilla 模板:[% 和 [%+] 有什么区别?
Bugzilla 模板中的代码通常由 [% 和 %] 分隔。但有时我会看到[%+和[%-]。有人可以解释其中的差异或向我指出合适的文档吗?这次谷歌让我失望了。
例如:
[%- event.value.subject FILTER html %]
或
[%+ END %]
Code in Bugzilla templates is usually delimited by [% and %]. But sometimes I see [%+ and [%-. Can someone explain the difference or point me at suitable documentation? Google has failed me on this occasion.
For example:
[%- event.value.subject FILTER html %]
or
[%+ END %]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[%-
(或-%]
)删除前导(尾随)空格;[%+
(或+%]
)维护它。请参阅模板工具包手册中的 PRE_CHOMP、POST_CHOMP(Bugzilla 模板使用Template Toolkit)了解详细信息(包括[=
和[~
:))。[%-
(or-%]
) removes leading (trailing) whitespace;[%+
(or+%]
) maintains it. See PRE_CHOMP, POST_CHOMP in the Template Toolkit Manual (Bugzilla templates use the Template Toolkit) for the gory details (including[=
and[~
:)).以下是我去年为我们团队写的内容:
我对 TT 行为的了解比我应有的要少,而我们团队的另一名成员向我承认,他比我更了解!
这是对咀嚼工作原理的简要说明。
假设我有以下模板,其中变量 x = 'foo'
将变为
注意第二行开头的空格。
TT 具有 PRE_CHOMP 和 POST_CHOMP 的配置设置。
如果 PRE_CHOMP 为 1,则删除指令前面的所有空格(包括换行符)。该示例变为
如果 POST_CHOMP 为 1,则另一端发生相反的情况:
如果 PRE/POST_CHOMP 为 2,则所有前面/后面的空格将折叠为单个空格:
如果 PRE/POST_CHOMP 为 3,则所有前面/后面的空格已消除:
==重要==
Bugzilla 配置为 PRE_CHOMP = 1。未设置 POST_CHOMP。
您可以在“[%”之后或“%]”之前使用字符 -、=、~ 和 + 之一明确表示咀嚼行为。 '-' 表示 CHOMP 级别 1,= 表示 CHOMP 级别 2,~ 表示 CHOMP 级别 3,+ 表示无论整体配置中是否设置,均不进行 chomping。
重复这个例子:
因为我们有 PRE_CHOMP = 1,所以这将变成
; foo
变成
foo
最后,
变成
对于更详细的解释,请执行 'perldoc Template::Manual::Config' 并搜索对于 CHOMP。
Here's something I wrote for our team last year:
I was less informed about TT's behavior than I should have been, and another member of our team has confessed to me that he was even less informed than I was!
This is a brief explanation of how chomping works.
Suppose I have the following template, with the variable x = 'foo'
will become
Note the spaces at the beginning of the second line.
TT has configuration settings for PRE_CHOMP and POST_CHOMP.
If PRE_CHOMP is 1, then all the whitespace in front of a directive, including a newline, is removed. The example becomes
If POST_CHOMP is 1, then the opposite occurs on the other end:
If PRE/POST_CHOMP is 2, then all preceding/succeeding whitespace is collapsed to a single space:
If PRE/POST_CHOMP is 3, then all preceding/succeeding whitespace is eliminated:
==IMPORTANT==
Bugzilla is configured with PRE_CHOMP = 1. POST_CHOMP is not set.
You can explicitly denote chomping behavior with one of the characters -, =, ~, and + after the '[%' or before the '%]'. '-' denotes CHOMP level 1, = denotes CHOMP level 2, ~ denotes CHOMP level 3, + denotes no chomping regardless of whether it is set in the overall configuration.
So to repeat the example:
Because we have PRE_CHOMP = 1, then this will become
becomes
becomes
<td> foo </td>
becomes
<td>foo</td>
Finally,
becomes
For an even more verbose explanation, do 'perldoc Template::Manual::Config' and search for CHOMP.