Eclipse plugin for Closure Templates

Overview

This plugin extends the Eclipse IDE by providing handy features to edit and compile Closure Templates files.

Syntax coloring
Syntax coloring
Syntax is automatically colored in the Closure Templates editor as you type.
Outline view
Outline view
The outline view provides an overview of your file, and an easy access to its templates.
Error
Errors and warnings
Potential errors in your template file are detected in background and signaled by problem markers.
Variable linking
Variable and template name linking
Variable and template name uses are automatically linked to their definition, allowing navigation and detection of undefined names.
Launch configuration
Launch the Closure Templates compiler
Create launch configurations for template files, and run them directly from their contextual menu.

If you are also using the the Closure Compiler, the Closure Library and/or the Closure Linter, you may have a look to the Eclipse plugin developed for them.

Installation

Requirements

The plugin should run on all platforms where Eclipse and Closure Templates are supported.

Step 1: Install Base Software

In order to use the plugin, you need:

Step 2: Install the plugin

Note: When installing the plugin, the Eclipse installation tool will automatically install required plugins from Eclipse repository (including Xtext).

How to use it?

Once you have installed the plugin, you just need to create a file with the file extension .soy in any project. This file will automatically be opened with the customized editor for Closure Templates. You may register additional file extensions for template files in the Eclipse Preferences (menu Window, then Preferences...), section General > Content Types.

Configuring errors and warnings. You can enable/disable some warnings on a per-project basis. For this purpose, open the properties for the project, and open the tab "LESS validation".

Launching the compiler. In order to launch the Closure Templates compiler from Eclipse, you need to create a launch configuration. For this:

Once this is done, you may compile any template file by selecting it in the project explorer, clicking on the right button to open the contextual menu and selecting Run as, Closure Templates Compiler. This will use the default launch configuration you just created. You can also create specific launch configurations for each of your stylesheet.

Custom functions and print decorators.The Closure Template compiler allows to define custom functions and print directive in plugins. If you are using such plugins, you need to declare the custom functions or print directive, so that they are recognized in Eclipse. See the following example:

{namespace example}

// This declares a custom JavaScript function having 1 required
// argument, and 2 optional ones.
// @function myFunction 1 2

// This declares a custom print directive having 1 required
// argument, and 2 optional ones.
// @printDirective myPrintDirective 1 2

/** */
{template .test}
  {print myFunction(1)|myPrintDirective:1,2}
  {print myFunction(1, 'b')}
  {print myFunction(1, 'b', 1)}
{/template}
    

If you do not want to include these declarations in your working files, you may create a specific .soy file in your project for this purpose. These declarations are exported in the same scope as templates.

License

The plugin is distributed under the Eclipse Plublic License Version 1.0.

History

Known issues

The following features are not supported in the editor: