I’m running a Play! app using Scala templates. However, I can’t find an elegant method to access the Cache in an elegant (or valid) way inside of html templates.
I’ve tried everything like:
<some html>@play.cache.Cache.get(play.session.getId() + "-account")</some html>
But no luck. Thanks for the proper way to do this!
I found the methodology buried in the old 0.9 Scala documentation. For the time being it’s not super-easy but it’s 3min do-able. It requires adding a parameter to the controller and template like so:
In your controller, pass session as a parameter
At the top of your template, define the implicit variable:
Inside the template html, access it like so: