Castle NVelocity 包括变量而不是变量内容

发布于 2024-08-20 04:17:39 字数 756 浏览 6 评论 0原文

我正在使用 Castles 的 NVelocity Engine 来做一些模板工作。问题就在这里。我的几个模板工作正常,但其中一个却不能。

#foreach($i in $Items)
<div class="grid_3 folioItem"> <a rel="prettyPhoto[portfolio]" href="$i.Link" class="lightBox"><img src="$i.Image" width="220" height="125" alt="showcase" /></a>
  <h4>$i.ShortName</h4>
  <p>$i.LongName</p>
  <p><a class="button pngFix" href="$i.Link">$i.LinkText</a></p>
</div>
#end

由于某种原因,上面的代码只工作了一半。我得到了六组带有所有内部结构的 div 标签,但 Velocity 输出 $i.ShortName 而不是 $i.ShortName 上的内容。有知道这是为什么吗?如果我得到六个输出,我就会相信项目设置正确并且存在于速度模板中。但出于某种奇怪的原因,孩子们却没有。

现在,Items 是一个 List,我一遍又一遍地检查以确保我没有拼写错误成员的名称。

我缺少什么?

I'm using Castles' NVelocity Engine to do some template work. Here's the problem. Several of my templates work fine, but one of them isn't.

#foreach($i in $Items)
<div class="grid_3 folioItem"> <a rel="prettyPhoto[portfolio]" href="$i.Link" class="lightBox"><img src="$i.Image" width="220" height="125" alt="showcase" /></a>
  <h4>$i.ShortName</h4>
  <p>$i.LongName</p>
  <p><a class="button pngFix" href="$i.Link">$i.LinkText</a></p>
</div>
#end

For some reason, the above code works half way. I get six sets of the div tags with all the innards, but Velocity outputs $i.ShortName instead of the contents on $i.ShortName. Any clue why this is? If I get six outputs that would leave me to believe that Items is set up correctly and exists in the Velocity Template. But for some odd reason it's children don't.

Now Items is a List<CategoryItem> and I've checked over and over again to make sure that I haven't misspelled the names of the members.

What am I missing?

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

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

发布评论

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

评论(1

慕烟庭风 2024-08-27 04:17:39

好的。所以我发现(我认为)子对象似乎只会将它们的属性暴露给模板。例如:

public class Item{
   public string BadName;
   public stirng GoodName {
       get {
           return "Foo"
       }
   }
}

GoodName可以在模板中引用,但是BadName不能

Okay. So I figured it out (I think) it seems to be that sub objects will only expose their properties to the template. For instance:

public class Item{
   public string BadName;
   public stirng GoodName {
       get {
           return "Foo"
       }
   }
}

GoodName can be referenced in the template, But BadName cannot

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