playframework - Dynamic content in the root template in Play framework (Scala) -


i learning play framework & wondering how create dynamic sidebar/footer appear in root template & wouldn't need pass data explicitly when rendering every single view. read through the docs, , there nothing this.

in django create custom template tag this. there similar in play well? best / typical approach solve this?

how avoid passing parameters everywhere in play2? , http://jazzy.id.au/default/2012/10/26/passing_common_state_to_templates_in_play_framework.html quite helpful.

for example can have templates footer.scala.html, main.scala.html , header.scala.html.

main.scala.html can like:

@(title: string)(content: html)(implicit x: sometype)  <!doctype html>  <html>     <head>         <title>@title</title>         <link rel="stylesheet" media="screen" href="@routes.assets.at("stylesheets/main.css")">         <link rel="shortcut icon" type="image/png" href="@routes.assets.at("images/favicon.png")">         <script src="@routes.assets.at("javascripts/jquery-1.9.0.min.js")" type="text/javascript"></script>     </head>     <body>         @header() @* include header *@         @content  @* resolve "the content" index.scala.html *@         @footer() @* include footer *@     </body> </html> 

and page template example index.scala.html:

@(message: string)(implicit x: sometype)  @main("welcome play 2.1") {     content } 

the footer or header can consume x: sometype implicit method parameters deliver dynamic content.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -