Reputation: 123
<g:if test="${!request?.xhr}">
<!doctype html>
<html>
<head>
<meta name="layout" content="home">
</head>
<body>
<div class="row-fluid">
</g:if>
AJAX
<g:if test="${!request?.xhr}">
</div>
</body>
</html>
</g:if>
I get error: Grails tag [sitemesh:captureBody] was not closed.
In Config.groovy
I set grails.views.gsp.sitemesh.preprocess = false
but this doesn't help.
What way to use partial view with if statement.
Upvotes: 1
Views: 563
Reputation: 12238
You can check request.xhr
in the controller, and determine to render a template or a string based on the results of that if statement.
Upvotes: 1
Reputation: 66109
A better way to handle this in grails is to wrap a template containing the main content. For example:
//_body.gsp
AJAX
//view.gsp
<!doctype html>
<html>
<head>
<meta name="layout" content="home">
</head>
<body>
<div class="row-fluid">
<g:render template="body">
</div>
</body>
</html>
Then your controller can render the whole view on a regular request, or just the body on AJAX.
Upvotes: 1