문제

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?

도움이 되었습니까?

해결책

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

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

and:

#{get 'anyBlock' /}

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top