Starting with Scalate

scalateScalate: Scala Template Engine: like JSP without the crap but with added Scala coolness

Here is a one minute way to start playing with Scalate: 30 seconds to finish reading this + 15 seconds to calm inner excitement + 15 seconds to actually do it. Get ready.. it is that simple.

( Step 1 is OS X based, check these install instructions in case your OS is different ):

Step 1. Install Scalate ( makes sense to install Scala as well, if you don’t have it )

sudo brew install scala
sudo brew install scalate

Step 2. Create a Scalate project

scalate create guice org.dotkam scalatez

where “org.dotkam” is a user defined groupId and “scalatez” is a user defined artifactId [ hellllo maven ]

NOTE: "scalate create jersey org.dotkam scalatez" may give you "Invalid syntax: No such archetype 'jersey' possible values are (empty, guice)" depending on the current Scalate version. Don't be distressed: use 'guice' as shown above

Step 3. Run it

cd scalatez/
mvn jetty:run

Once you see

2011-01-07 14:28:42.597:INFO::Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server

Fire up the browser and go to “http://localhost:8080

Scalate Default Home Resource

DONE.

At this point you are good to start working with the Scalate project.
Let’s modify the current home page that you see in your browser:

vi src/main/webapp/WEB-INF/org/dotkam/scalatez/resources/HomeResource.index.scaml

once you save it, no need to restart: Jetty would pick you changes immediately ( e.g. “scanIntervalSeconds” parameter ), so just refresh that browser:

Scalate Custom Home Resource

4 comments

  1. Great post, thanks!

    BTW if you have TextMate installed, you can click on the Scalate icon on the web page (that icon top right with the + symbol next to it) then it will show links to the layout and current template. Clicking on the template will open it for editing in TextMate.

    You can switch to using Eclipse / IDEA if you like as your editor…
    http://scalate.fusesource.org/documentation/console.html

    Also if you do use TextMate, be sure to also include the Scalate bundle for nice syntax highlighting…
    http://scalate.fusesource.org/documentation/user-guide.html#TextMate_plugin

  2. This looks quite interesting. I read somewhere that it is easier to learn that it is very similar to JSP, but easier to learn. However, if that is the case, then how come I haven’t seen any job vacancies on this language?? Have I just not been looking hard enough??

  3. @Lifesize,

    It is not only easier to learn than JSP, it is much cleaner and makes a lot more sense than JSP :)
    Jobs in any technology are created by people, are you one of those? If yes, just use it on your existing/next project, this will contribute to all the new jobs that will follow.

    @James,

    Thanks for the tips, I am not a Textmate user (VI + IntelliJ), but it is definitely helpful for others!

    /Toly

tell me something...
  1. (required)
  2. (valid email - optional)
  3. Captcha
  4. (required)