0

I'm creating application using Scalatra and I'm using Scalate/Jade for templating. I try to add flash support to my application. I mixed FlashMapSupport into into my Servlet and I'm able to access flash helper. Anyway, if I'm trying to get it from layout I receive following error:

[error] /home/ytaras/projects/scala/scalatra-shopping-cart/target/scala-2.10/src_managed/main/scalate/templates/layouts/default_jade.scala:27: not found: value flash
[error]                         flash.get("alert").foreach
[error]                         ^
[error] one error found

The best I could do to avoid that was to use downcast to render context:

  - context.asInstanceOf[org.scalatra.scalate.ScalatraRenderContext].flash.get("alert").foreach
    - alert =>
    .alert
      .button(type="button" class="close" data-dismiss="alert") ×
      = alert

Anyway, that's definitely not a prettiest solution. Is there something I can do to fix it or it's an issue in Scalate/Jade code?

Yura Taras
  • 1,293
  • 14
  • 26

1 Answers1

1

I've just done a very simple Scalatra app using Jade, it seems to work as per the docs.

Edit: I had been working with an app generated in an earlier version of Scalatra.

In Scalatra 2.2.0, we added precompiled Scalate templates in the g8 skeleton, to give extra speed in production by default. There's an error in project/build.scala in there which causes flash context to get lost.

Add this to your project/build.scala: https://gist.github.com/anonymous/ff40cdde1a1105970f50#file-build-scala-L37-L39

We'll fix the g8 template momentarily. Sorry for the trouble.

futurechimp
  • 554
  • 4
  • 6
  • Could you clarify what type of info might help? Thanks – Yura Taras Apr 05 '13 at 12:01
  • Hi Yura, can you show the action and views, as I've done? Also, if you need real-time help, there's a very active community in the #scalatra irc channel on Freenode. – futurechimp Apr 05 '13 at 12:40
  • Sure - here's git repository I'm talking about - https://github.com/ytaras/scalate_shopping_cart – Yura Taras Apr 05 '13 at 13:08
  • Thanks! I'm checking with some other people now to see whether there's a bug here, I've reproduced your example in a standalone application. – futurechimp Apr 05 '13 at 14:53