Hello Everyone --

Does nVelocity give me a way to dereference variable names, such that
I can build variable names dynamically in my template?

Here is what I'm trying to do. In my controller I send some data to
the view with a dynamic name. For example:

  string type = "Widget";

  PropertyBag["type"] = type;
  PropertyBag[type + "Options"] = GetListOfOptionsByType(type);

Now I have two entries in my PropertyBag. One is called "type" and the
value is "Widget". The other is called "WidgetOptions" and the value
is a list of stuff.

Now, my nVelocity template knows the type ($type == "Widget") and it
knows that the options for that type are going to be stored in a
variable named after the type with "Options" appended to it,
i.e."$WidgetOptions". The problem, though, is that in order to
actually get to the list of options, I must build the second variable
name ($typeOptions) and then dereference it (?????). Do you see what I
mean?

I have tried lots of things:

  $$typeOptions
  ${$type}Options
  ${{$type}Options}

...just to name a few. I tried using #set and even looked at macros. I
have a feeling nVelocity cannot do what I am asking, but I would be
pleased to be proven wrong.


Thanks!

--Stuart
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to