如何在 StringTemplate 循环中使用 IF 语句

发布于 2024-08-08 02:04:50 字数 296 浏览 3 评论 0原文

这不显示任何内容:

$文章:{ $如果(i!=1)$ 在文章之间显示 $结束$ $it.Text
}

将按预期显示

$文章:{ 在文章之间显示 $it.Text
}

关于如何让它发挥作用有什么想法吗

This displays nothing:

$Articles:{
$if(i!=1)$
display in between articles
$endif$
$it.Text
}

This displays as expected

$Articles:{
display in between articles
$it.Text
}

Any ideas on how to get this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

孤檠 2024-08-15 02:04:50

您需要计算所有表达式并推入模板。您显然正在过滤,这应该在模型而不是视图中完成。请参阅:

http://www.cs.usfca.edu/ ~parrt/papers/mvc.templates.pdf

特伦斯

you need to compute all expressions and push into the template. You are clearly filtering, which shoul be done in the model not the view. Please see:

http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

Terence

故事还在继续 2024-08-15 02:04:50

此处,它表示 $if 测试是否存在属性或计算布尔表达式。唯一允许的运算符是 !(NOT),
所以也许你可以定义一个布尔变量 = (i!=1) 并在 $if 语句中使用它。

here, it says that $if tests for the presence of an attribute or evaluates a boolean expr. The only operator allowed is !(NOT),
so maybe you can define a boolean variable = (i!=1) and use it in the $if statement.

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