Apache Velocity 模板语言 - 忽略无效引用

发布于 2024-12-26 22:42:23 字数 361 浏览 3 评论 0原文

假设我想在VTL中解析这样的地图。

map - { "person" = "xyz", age="99" }

使用 VTL,我将调用 $map.person$map.age 在模板中插入适当的值。

现在假设地图不包含键“person”的任何有效值,

map - { age="99" }

如果我调用 $map.person ,VTL 将简单地返回 $map.person我想完全忽略这样的引用被解析。我怎样才能实现这个目标?

Suppose I want to parse a map like this in VTL.

map - { "person" = "xyz", age="99" }

Using VTL, I would call $map.person and $map.age to insert the appropriate values in the template.

Now suppose the map does not hold any valid value for the key "person"

map - { age="99" }

If I call $map.person , VTL simply will return $map.person. I want to ignore such a reference from being parsed at all. How can I achieve this?

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

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

发布评论

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

评论(1

胡渣熟男 2025-01-02 22:42:23

无声记号。是的,手册上有。

$!map.person

silent notation. yep, it's in the manual.

$!map.person

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