Skip to content
Jedd Haberstro edited this page Aug 2, 2013 · 9 revisions

A Play2 Template is a simple text file that contains small blocks of Scala code. Templates can generate any text-based format, such as HTML, XML or CSV.

Below follows the set of features that are currently supported for Template files.

  • Scala Editing
    • As-you-type Error Reporting
    • Auto Indentation
    • Completion Proposals
    • Hyperlinking
    • Syntax Highlighting
    • Text Hover
  • HTML Editing (as of Play2 plug-in 0.4.0)
    • Anchor-tag Hyperlinking
    • Code Folding
    • Content Outlines and Quick Outlines
    • Completion Proposals
    • Javascript and CSS Syntax Highlighting
    • Matching Tag Navigation and Highlighting
    • Text Hovering

A more detailed overview of the above features follow below.

Scala Features

As-you-type Error Reporting

It shows compilation errors, in two levels.

  • Compiling from template file into scala file.

Template Error Template Preview

  • Compiling result scala file.

Template Error Scala Preview

Auto Indentation

The template editor follows a very simple heuristic to automatically indent after a new-line character. By default, it indents to the previous line, except if there is an open parenthesis/brace on the current line, when it increases the indent by the tab size.

You can control the tab size and the tab-vs-spaces setting in the Editors -> Text Editors Eclipse configuration.

Tab and spaces setup

Completion Proposals

By using CTRL+SPACE (COMMAND+SPACE on Mac OSX) you can get the usual code completion popup inside Scala fragments.

Template Code Completion Preview

Hyperlinking

You can hyperlink to elements of another Scala source file (Hyperlinking for elements of another template file or java file is not supported at the moment).

Template Hyperlinking Preview

Syntax Highlighting

Syntax Highlighting for:

  • HTML Tags: It provides different coloring for attributes, tag name, values, and string literals.
  • Scala Code: It provides different coloring for different tokens of scala.
  • Comments

Template Syntax Highlighting Preview

Also it has preference for Play2 Template custom keywords:

Template Preference Page for Syntax Coloring Preview

Text Hover

Whenever you go over a Scala identifier, it will show you its type.

Template Text Hover Preview

HTML Features

As of the Play2 0.4.0 plugin, the template editor sports a new array of HTML source-editting features.

Anchor-tag Hyperlinking

Hyperlink jump to files or websites of an anchor-tags' href path.

Code Folding

Expand or contract blocks of code.

HTML Code Folding

Content Outlines and Quick Outlines

Quickly find, view, and jump between different regions of code. Activate the Quick Outline by press CTRL+O (CMD+O on Mac OS X).

HTML Content Outline HTML Quick Outline

Completion Proposals

Just like in Scala code, press CTRL+SPACE (COMMAND+SPACE on Mac OSX) to get code completion proposals of both HTML tags and attributes.

HTML Completion Proposals

Javascript and CSS Syntax Highlighting

Within script and style tags, Javascript and CSS code will be syntax highlighted.

Javascript and CSS highlighting

Matching Tag Navigation and Highlighting

Quickly identify start and end tags, and jump between them.

Matching Tag Highlighting

Matching Tag Navigation

Text Hovering

Hover your mouse over HTML elements to get a popup containing the elements description.