开发者

Castle NVelocity Including Variables not Variable contents

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

开发者_JAVA百科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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜