views:

36

answers:

1

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?

A: 

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

Timothy Baldridge
see http://svn.castleproject.org:8080/svn/castle/NVelocity/trunk/src/NVelocity/App/FieldMethodizer.cs for rationale
Mauricio Scheffer