Skip to content

Instantly share code, notes, and snippets.

@thbkrkr
Created January 11, 2013 09:36
Show Gist options
  • Save thbkrkr/4509319 to your computer and use it in GitHub Desktop.
Save thbkrkr/4509319 to your computer and use it in GitHub Desktop.
Play2 Scala Template with PJAX
@(title: String, styles: Html = Html(""), scripts: Html = Html(""))(content: Html)(implicit request: play.api.mvc.Request[play.api.mvc.AnyContent])
@* Check for the pjax header *@
@if(request.headers.get("X-PJAX").isDefined) {
<title>@title</title>
@content
<script>console.log("pjax template loaded");</script>
} else {
@* Normal request, not pjax *@
<!DOCTYPE html>
<html>
<head>
@header(title)
@styles
</head>
<body>
<div id="content">
@content
</div>
<script data-main="@routes.Assets.at("js/app.min.js")" src="@routes.Assets.at("js/require-jquery.min.js")"></script>
@scripts
@ga()
<script>
</script>
</body>
</html>
} @* End else *@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment