[Nitro] Passing data from a controller to a template

James Britt james_b at neurogami.com
Fri Jun 2 04:06:59 EDT 2006

Lars Olsson wrote:
> Hi list!


> ... 
> This moves both the programming logic and the template data into the same
> space, but I want them separated, like this:
> class MyController < Nitro::Controller
>   def foo
>     title = 'Page title'
>     content = 'Some content...'
>     # pass title and content too foo.xhtml and render the template
>   end
> end

class MyController < Nitro::Controller
   def foo

   # Make these instance attributes
      @title = 'Page title'
      @content = 'Some content...'


Then, in foo.xhtml, refer to @title and @content.

James Britt

"Judge a man by his questions, rather than his answers."
  - Voltaire

More information about the Nitro-general mailing list