Bugzilla 模板:[% 和 [%+] 有什么区别?

发布于 2024-08-19 12:36:42 字数 210 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦回梦里 2024-08-26 12:36:42

[%-(或 -%])删除前导(尾随)空格; [%+(或+%])维护它。请参阅模板工具包手册中的 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 [~ :)).

む无字情书 2024-08-26 12:36:42

以下是我去年为我们团队写的内容:

我对 TT 行为的了解比我应有的要少,而我们团队的另一名成员向我承认,他比我更了解!

这是对咀嚼工作原理的简要说明。

假设我有以下模板,其中变量 x = 'foo'

<td>
  [% x %]
</td>

将变为

<td>
  foo
</td>

注意第二行开头的空格。

TT 具有 PRE_CHOMP 和 POST_CHOMP 的配置设置。

如果 PRE_CHOMP 为 1,则删除指令前面的所有空格(包括换行符)。该示例变为

<td>foo
</td>

如果 POST_CHOMP 为 1,则另一端发生相反的情况:

<td>
foo</td>

如果 PRE/POST_CHOMP 为 2,则所有前面/后面的空格将折叠为单个空格:

<td> foo </td>

如果 PRE/POST_CHOMP 为 3,则所有前面/后面的空格已消除:

<td>foo</td>

==重要==

Bugzilla 配置为 PRE_CHOMP = 1。未设置 POST_CHOMP。

您可以在“[%”之后或“%]”之前使用字符 -、=、~ 和 + 之一明确表示咀嚼行为。 '-' 表示 CHOMP 级别 1,= 表示 CHOMP 级别 2,~ 表示 CHOMP 级别 3,+ 表示无论整体配置中是否设置,均不进行 chomping。

重复这个例子:

<td>
  [% x %]
</td>

因为我们有 PRE_CHOMP = 1,所以这将变成

<td>foo
</td>

<td>
[%- x -%]
<td>

<td>foo</td>

<td>
[%= x =%]
</td>

; foo

<td>

[%~ x ~%]

</td>

变成 foo

最后,

<td>
  [%+ x %]
</td>

变成

<td>
  foo
</td>

对于更详细的解释,请执行 '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'

<td>
  [% x %]
</td>

will become

<td>
  foo
</td>

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

<td>foo
</td>

If POST_CHOMP is 1, then the opposite occurs on the other end:

<td>
foo</td>

If PRE/POST_CHOMP is 2, then all preceding/succeeding whitespace is collapsed to a single space:

<td> foo </td>

If PRE/POST_CHOMP is 3, then all preceding/succeeding whitespace is eliminated:

<td>foo</td>

==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:

<td>
  [% x %]
</td>

Because we have PRE_CHOMP = 1, then this will become

<td>foo
</td>

<td>
[%- x -%]
<td>

becomes

<td>foo</td>

<td>
[%= x =%]
</td>

becomes <td> foo </td>

<td>

[%~ x ~%]

</td>

becomes <td>foo</td>

Finally,

<td>
  [%+ x %]
</td>

becomes

<td>
  foo
</td>

For an even more verbose explanation, do 'perldoc Template::Manual::Config' and search for CHOMP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文