How to pass a script to main.scala.html - Play! 2

前端 未结 2 1648
清酒与你
清酒与你 2021-01-22 11:16

I am trying to pass javascripts specific to a page as a parameter to the main template. This is what I have tried:

main.scala.html:

@(ti         


        
2条回答
  •  萌比男神i
    2021-01-22 11:57

    I struggled with this as well, but this seemed to work for me:

    main.scala.html:

    @(title: String, moreScripts: Html = Html(""))(content: Html)
    
    
      
       @title
       @moreScripts
      
      
       @content
      
    
    

    test.scala.html:

    @moreScripts = { }
    
    @main("Page Title", moreScripts) {
      

    Some content here

    }

    Of course, your Javascript file should be located at app/assets/javascripts as either a standard Javascript or Coffeescript file

提交回复
热议问题