Fork this page on GitHub

Getting Started

Lets get scalating!

Introduction

Lets try and get you up to speed using Scalate as quickly as possible.

This guide will assume you have a reasonably recent installation of Maven, say version 2.0.9 or later. If you don't, please install one now.

Note that if you hit any issues during this guide you might want to check out the FAQ.

Create a project

Lets create a new webapp project that we can use as a base on which to build. If you have not done so already, install the Scalate Tool. Now to create a new project run:

  scalate create jersey mygroup myartifactid

Change the mygroup and myartifactid to whatever maven group id and artifact id you want to use.

Now change directory to the newly created myartifactid directory (or whatever name you used for the artifact id)

  cd myartifactid

You should now see a directory tree something like this

  src
    +--main
    |  |--resources
    |  +--scala
    |  |  |--mygroup
    |  +--webapp
    |     |--WEB-INF
    +--test
       +--scala
          |--mygroup

If this step didn't work, let us know!

This has created a basic skeleton module that be be built using SBT or Maven which generates a web application which has Scalate integrated.

Building with Maven

To run the project run the following Maven command

  mvn jetty:run

Now when the application starts up you should be able to point your browser at http://localhost:8080 to run the application.

Your application is now ready for you to create new JAXRS resource beans (in Scala or Java code) as well as rendering any Scalate templates in the src/main/webapp directory.

To start hacking on a template, try editing the src/main/webapp/index.scaml file which is used to render the home page (a Scaml template). Or try adding new templates.

Building with SBT

You can also compile the code with SBT (or Simple build tool) if you prefer instead of Maven. Type the following commands into a terminal (the first command enters the SBT shell)

  sbt
    update
    compile

Scalate Console

While looking at the home page of your running application you should see a little icon near the top right of the screen which opens/closes the Scalate Console. Try opening it and try out its links.

The Scalate Console provides nice error messages if you make a typo in a template together with edit links to the source code, plus provides handy links to the current source, templates and layouts you are viewing in development mode along with a number of other features.

Please refer to the Console documentation for more detail.

Diving deeper

Once you have the application working and you've played with the Console you might want to dive deeper into Scalate and understand how it works.