Anthony Shull
Anthony Shull

Reputation: 1095

How do I add dynamic content to main.html outside of doLayout in Play Framework

I have dynamic content that I would like to display on every page in my application. I'm only using one template(main.html). I can render the content for every controller and then main.html has access to it, but I figure there has to be a cleaner way to include content outside of the doLayout tag.

Upvotes: 1

Views: 1161

Answers (2)

Codemwnci
Codemwnci

Reputation: 54924

The most common way to do this, is to use a @Before interceptor in your controller to get the dynamic elements, and to store it in the renderArgs, and then to place the dynamic content in your view by editing the main.html.

I think the question answers your question succinctly - Does Play Framework support "snippets"?.

Upvotes: 2

ASX
ASX

Reputation: 1725

As doLayout is a custom tag, you can create a new one of your own and have any content you need, within your logic.

Upvotes: 0

Related Questions