Question

I'm having a problem when trying to use layouts in the Play! Framework. As far as I know, a layout has a SINGLE #{doLayout /} tag that specifies where all the code of the child view should be placed. This means that all the code in a particular view of, say, list of Users (list.html) gets injected in the middle of the body of the layout. Now, I find that some of my views require javascript that is particular to those views, and so I'd like to include script tags only on those views and not on every single view that inherits from the layout. The Razor view engine in ASP.NET MVC allows for different sections in a layout that are filled in by a view that extends that layout, but I don't know if Play supports something like this.

Do you see a solution to this problem?

Was it helpful?

Solution

You can also use the #get,#set tags to define other blocks. For example:

#{set 'anyBlock'}
     <h1>Main title</h1>
#{/set}

and:

#{get 'anyBlock' /}

OTHER TIPS

You can use the script tag in your specific views. For instance :

#{script 'jquery.js' /}

I recommend you to read this documentation page :

http://www.playframework.org/documentation/1.1/tags#script

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top