Setting object variables

10 views
Skip to first unread message

Jeff Schnitzer

unread,
Feb 8, 2012, 8:11:25 PM2/8/12
to cambridge...@googlegroups.com
Often time I have a complex object I'd like to break down in a template.  For example, a TicketModel might have an Organization, Event, Person.  For a variety of reasons mostly related to code re-use, I don't want to use expressions like ${ticket.event.blah} and ${ticket.org.blah} everywhere.  I just want to set a few variables like I would have done in Velocity (or JSTL or any other template):

#set ($event = $ticket.event)
#set ($org = $ticket.org)
#set ($person = $ticket.person)

The closest thing I can find in the cambridge docs is a:with, which means I have to do something like this:

<a:span a:with="ticket.event" a:as="event">
   <a:span a:with="ticket.org" a:as="org">
      <a:span a:with="ticket.person" a:as="person">
         ...all my code
      </a:span>
   </a:span>
</a:span>

This is really heavy handed and makes a big mess every time I want to add a new alias.  Is there some way to make a simple set-variable?  I've tried variations on <--$set but it seems to only handle strings and not object references.

Thanks,
jeff

erdincyilmazel

unread,
Feb 8, 2012, 9:19:55 PM2/8/12
to cambridge...@googlegroups.com, cambridge...@googlegroups.com
There is the set directive in Cambridge as well. I really need to get the documentation complete don't I? :(

<!--$set event = ticket.event -->

Sent from my iPad

Jeff Schnitzer

unread,
Feb 8, 2012, 10:12:05 PM2/8/12
to cambridge...@googlegroups.com
Ah, of course.  I had tried <!--$set with several combinations of quoting and ${}ing but never thought to just leave it without either.  Thanks.

Jeff
Reply all
Reply to author
Forward
0 new messages