Need help setting Scalate engine settings with Spring integration

38 views
Skip to first unread message

Jon Wu

unread,
May 6, 2014, 9:03:55 PM5/6/14
to sca...@googlegroups.com
Hi,

I need some help with a few issues I've run into after I started using scalate-spring-mvc. I'm pretty stumped so any help would be really useful!

I'm having the following problems:

1. When updating jade templates in production without restarting the server, everything will break.

I'm assuming this is because I'm not running in development mode or maybe don't have allow reload enabled with the Spring MVC integration. I used to setup my engine with options like this, but how do I do that with the Spring MVC integrations?

  private static final TemplateEngineFacade ENGINE_FACADE = new TemplateEngineFacade();
  private static final TemplateEngine ENGINE;
  static {
    ENGINE_FACADE.setMode("development");
    // Class loader can't see servlet stuff automatically for some reason - this hack fixes that
    ENGINE.classpath_$eq("lib/servlet-api.jar");
    ENGINE.allowCaching_$eq(true);
    ENGINE.allowReload_$eq(true);
  }

2. Number format settings don't work randomly
Because I output numbers to be parsed in JavaScript, the default settings that separate by commas break my code. I need to change the default number format globally.

For some reason, when I have code like this in a jade template now, the number formatting doesn't work in rare cases. Perhaps there's a race condition happening when I try to set this in the template:

  - numberFormat.setGroupingUsed(false)
    :&plain
      var google_tag_params = {
        ecomm_totalvalue: #{product.getHighestPrice.toString}
        ...
      };

Before using scalate-spring-mvc, I used to layout templates like this:

    ...
    final DefaultRenderContext context = new DefaultRenderContext(fullUri, ENGINE, new PrintWriter(buffer));
    final DecimalFormat df = new DecimalFormat();
    df.setGroupingUsed(false);
    context.numberFormat_$eq(df);
    ...
    ENGINE.layout(template, context);

How do I do the equivalent now with scalate-spring-mvc?

3. How do I make sure the scalate classloader can see all classes?

This is unrelated to Spring MVC as I'm calling the engine directly (using some of the code in #1) to send out emails. I have classes in app / directory A, common, and app B all loaded up in Tomcat, but Scalate only sees classes in app A and can't see classes in app B when I use it from there.

Thanks for your help!
Jon
Reply all
Reply to author
Forward
0 new messages