13

I have a template that exists under views/dashboard/_myTemplate.gsp and from the DashboardController I can simply call

render template:'myTemplate'

and all is well. I have a need to render this template from a different controller but the render method doesn't allow you to specify a controller and I can't seem to figure out how to define the path at which the template exists for the render to work correctly. Is this even possible?

Nix
  • 57,072
  • 29
  • 149
  • 198
Gregg
  • 34,973
  • 19
  • 109
  • 214

1 Answers1

28

You do it by controller name:

render(template:'/dashboard/myTemplate')
chrislatimer
  • 3,560
  • 17
  • 19
  • 3
    It helps-me a lot! And if your want to use a view from another controller, use: render view: '/fooController/barView' – Topera Aug 30 '11 at 13:45
  • 1
    technically this is not the controller name, it's the path to the template relative to the `views` directory. – Ken Liu Oct 31 '13 at 17:27