[Nitro] Passing data from a controller to a template

Lars Olsson lasso at lassoweb.nu
Fri Jun 2 03:03:36 EDT 2006


Hi list!

I'm a bit confused about the relationshop between the controller and the
template when rendering pages.

Lets say I have a simple template (foo.xhtml):

<html>
  <head>
    <title>#{title}</title>
  </head>
  <body>
      #{content}
  </body>
</html

I now I can fill the template by using the <?r ?> tags:
<?r
title = 'Page title'
content = 'Some content...'
?>

However, sometimes I feel it would be nicer to put the programming logic
in a separate space (MVC style). So I create a controller:

class MyController < Nitro::Controller
  def foo
    title = 'Page title'
    content = 'Some content...'
    #{
    <html>
      <head>
        <title>#{title}</title>
      </head>
      <body>
        #{content}
      </body>
    </html
    }
  end
end

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

How do I acomplish this within Nitro? Is it possible?


Kindly

/Lasso

-- 
________________________________________
Lars Olsson
lasso at lassoweb.nu
http://www.lassoweb.nu/




More information about the Nitro-general mailing list