1. ActiveGrade
  2. Untitled project
  3. soy-ant

Overview

Ant Task for Soy Templates

NOTE: Soy Templates are also known as Google Closure Templates

Purpose

This project creates an Ant task to compile Soy templates into JavaScript

Obtaining

The project is available as a Mercurial (hg) repository at BitBucket

The bitbucket site allows you to download the source (including all revision history) through Mercurial, or download an archive of the latest version of the source (e.g. as a zip file)

A precompiled jar file is also available at the bitbucket download page.

Building

The included ant build file (build.xml) should be enough to build the project from scratch. It will download the latest Soy compiler. If you have an existing Soy compiler that you want to use, copy the jar file into the lib directory before you build.

The default ant target will compile and generate a jar file in output/ant

Usage

To use the task in your ant projects follow these steps

  1. Copy the file soy-ant-X.X.jar (from output/ant/ or the bitbucket download page) into an appropriate location in your project
  2. Copy the soy compile jar SoyToJsSrcCompiler.jar (from lib/) into an appropriate location in your project
  3. In your ant build file (build.xml) define the soyc task (see below)
  4. In your ant build file (build.xml) use the soy task as per the example below

Example

<taskdef name="soyc" classname="com.activegrade.tools.soy.ant.SoyCompileTask" classpath="SoyToJsSrcCompiler.jar:soy-ant-X.X.jar" />`

<soyc todir="build/war/templates/" >
    <fileset dir="src" >
        <include name="**/*.soy" />
    </fileset>
    <mapper type="flatten" />
</soyc>

Supported Attributes

todir - required
The destination directory for the JavaScript output. By default the output files will have the same name as the corresponding input file with .soy replaced with .js. The original directory structure will be recreated under the todir directory. This behaviour can be altered with a nested <mapper>

checktimestamps - default: true
Whether to check the timestamp of the input and output files. If enabled then compilation will be skipped if the output file is newer than the input file.

globals - default: none
Corresponds to the --compileTimeGlobalsFile option in the soy commandline compiler

codestyle - default: STRINGBULDER ; Allowed values: STRINGBUILDER , CONCAT , stringbuilder , concat
Corresponds to the --codeStyle option in the soy commandline compiler

generatejsdoc - default: false
Corresponds to the --shouldGenerateJsdoc option in the soy commandline compiler

useproviderequire - default: false
Corresponds to the --shouldProvideRequireSoyNamespaces option in the soy commandline compiler

declarenamespaces - default: true
Corresponds to the --shouldDeclareTopLevelNamespaces option in the soy commandline compiler

Nested Elements

<fileset> - required
An ant fileset that provides the soy source files.

<mapper> - default: glob *.soy => *.js
An ant mapper that maps a source filename to one or more output filenames.

License

This project is licensed under the Apache License, Version 2.0
The license in included in this project in the file LICENSE, or it can be obtained at the Apache site

Contact

This project is sponsored by ActiveGrade LLC.
For bugs or feature requests, please create an issue at BitBucket