Fork this page on GitHub

How to create a Scalate IDE

We love awesome IDEs! :)

Scalate the IDE friendly template language

We specifically designed Scalate so that it should work amazingly well in an IDE since all expressions in the templates are Scala using static typing so that when you are editing a template the IDE knows all of the attributes and their types.

Your IDE should be capable of great completion and error checking; plus at edit time your IDE should know if you have made any typos in any of your expressions such as maybe getting the property name wrong on a bean you are displaying. Its very easy to make typos in templates!

Making it easier on the IDE hacker

Making great IDE plugins is a lot of work, but we hope we can cut some corners making great IDE plugins for Scalate because:

JSR 45 Support

Scalate adds JSR 45 metadata to the template classes that it generates. This means that, when running in Java a debugger, browsing through stack frames of generated template classes will take you to the template file instead of the generated scala file. This feature should also allow IDE implementors to create Ssp and Scaml editors which allow you to set debugging breakpoints in the templates.

Types in scope for the Scala language completion

Other than detecting when there is a Scala code block or expression in the Ssp and Scaml template languages, the main thing for the IDE to do is to configure which variables are available and their types for error checking and completion. Here's a break down…

For example the following Ssp script:

<%@ val bar: String = "this is the default value" %>
<%@ import val foo: Customer %>
<p>hello there ${name} and ${bar}</p>

could be considered to mean the following scala code (using << to refer to rendering output)

def render(context: ServletRenderContext, 
           bar: String = "this is the default value", 
           foo: Customer): Unit = {

  import context._
  import foo._
  << "<p> hello there"
  << name
  << " and "
  << bar
  << "</p>"

The purpose of the above isn't to give a faithful representation of how output is generated (its similar to the above but you could always look at the actual generated scala code in WEB-INF/_scalate/src/foo.ssp.scala to see for sure) - its more to show what variables are in context for the purpose of compiler warnings and method completion.

So in the above the “name” expression is resoved by the foo variable's import for example.

We're here to help!

If you are considering hacking an IDE plugin for Scalate we're more than happy to help you out, please get in touch! Many thanks!