[Nitro] Passing data from a controller to a template

Jonathan Buch john at oxyliquit.de
Fri Jun 2 18:55:50 EDT 2006


>> Then, in foo.xhtml, refer to @title and @content.
> Is there a way to do this using accessors instead of instance variables?

You are aJavaFan(String newTitle), aren't you ;D

No seriously, using instance variables is the correct way here (calling
methods should be done in the Controller anyway) but you could sure
create extra functions (accessors) for all your instance variables.

class MyController
   attr :foo

   # public stuff 'n actions goes here


   def setFoo(f); @foo = f; end
   def getFoo; @foo; end


But... aint that ugly?

Basically, the foo.xhtml IS the Controller instance, so you can do
everyting you can do in the controller, no limits here, nitro is all
about freedom ;)

But you should be careful with that, don't call yourself or any other
called part via a function() calls or you get yourself nice limitless
recursive template compiler calls :)


Feel the love

More information about the Nitro-general mailing list