Community contributed extensions

Scalate support

Scalate is a template engine written in scala. It supports two dialects: ssp (jsp for scala) and scaml (haml for scala). Play provides integration for both via a special Controller class.

Getting started

first you need to grab the release from the modules repository:

play install scalate-0.1

Starting a New Project

then if you start a new project all you need to do is:

play new myapp --with scala,scalate

(if you have any other version installed from scala or scalate than 0.1, then you will need to explicitly reference both ie. --with scalate-0.1,scala-01)

the scalate module is depending on the scala module, so both modules need to be installed and activated

Existing Projects

or if you want to configure an existing scala project, you will need to edit your conf/application.conf:

module.scalate=${play.path}/modules/scalate-0.1

and set the dialect:

scalate=ssp

or

scalate=scaml

then you will also need to increase the heap size:

jvm.memory=-Xmx256M -Xms32M

finally you will need to change your controllers to inherit from play.mvc.ScalateController

Example

object Application extends ScalateController  {
    def index(name: String = "Guest user") = renderScalate(name)
}

if the method above is invoked, play will render app/views/Application/index.ssp with the following context variables already populated:

Difference between production and dev mode

in dev mode, play will alow instant template reloading, that is, if you make a change to a template and refresh the page, the change will apear. In production, however, template reloading is disabled for performance reasons.

layout

scalate now supports layouts, partials as well. Play stores default layouts in app/views/default.ssp (or app/views/default.scaml).

Reverse URL

<%= url("Application.index") %>

this will give back the index page

<%= url("Application.something", Map("id"->5)) %>

this will resolve method “Application#something” with argument “id”

<%= absoluteurl("Application.index") %>

this will resolve the full url

<%= staticurl("/public/images/favicon.png") %>

this will resolve the full url for the favicon asset.