How to Render a Grails View Without a Layout

615 views Asked by At

If you have a controller action, but don't want the view to be rendered with the default layout (in my case layout/main.gsp), is there a render option you can enter into the controller action or something similar?

def comingSoon {
  static layout = none;  //not correct, but something like this?
}
3

There are 3 answers

0
Joshua Moore On

Without more details it's difficult to say 100% what case you are in so I'll attempt to answer both.

If you are using dynamically scaffolded views then you'll need to generate the GSPs so you can remove the <meta name="layout" tag from them. This will keep any layout from being used.

Alternatively you could alter the scaffolding templates (within the scaffolding plugin) to include some additional logic about not applying a layout when the domain class has some static property (as your question contains).

0
elixir On

In your view file, you might see something like this

<html>
<head>
    <meta name="layout" content="main"/>  // delete this line
    <title>Coming Soon</title>
</head>
...

Remove the meta tag with the name="layout". This meta tag is the one that tells sitemesh to use the main layout

0
Syed Sarek On

You can remove <meta name="layout" content="main"/> to vanish exists layout. Or you may customize layout by edit that main.gsp page in your-project\grails-app\views\layouts\