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>
<?r
title = 'Page title'
content = 'Some content...'
?>
class MyController < Nitro::Controller
def foo
title = 'Page title'
content = 'Some content...'
%[
<html>
<head>
<title>#{title}</title>
</head>
<body>
#{content}
</body>
</html
]
end
end
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
(1 attempts)
Fabian answered:
You're almost there.
MVC-style:
Controller (C) controller.rb:
class MyController < Nitro::Controller def foo @title = 'Page title' @content = 'Some content...' end end
Template (View/V) foo.xhtml:
<html> <head> <title>#{@title}</title> </head> <body> #{@content} </body> </html>