Skip to content

Instantly share code, notes, and snippets.

@bendman
Last active October 8, 2015 19:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bendman/3381516 to your computer and use it in GitHub Desktop.
Save bendman/3381516 to your computer and use it in GitHub Desktop.
Sublime Text 2 - Google Closure Template Builder
{
"cmd": ["java", "-jar", "../SoyToJsSrcCompiler.jar", "--outputPathFormat", "../${file_base_name}.js", "${file}"],
"selector": "source.soy"
}
@bendman
Copy link
Author

bendman commented Aug 17, 2012

First, if it's not already in your repository, get the Google Closure Template compiler at their documentation website:
https://developers.google.com/closure/templates/docs/helloworld_js
or the direct link:
http://closure-templates.googlecode.com/files/closure-templates-for-javascript-latest.zip

Create a new Sublime Text 2 build system (Tools > Build System > New Build System...), pasting in the code above.

Set the 3rd "cmd" item in the sublime-build file to reflect the compiler location.

NOTE: With the current setup, it will build any .soy file into a .js file and place it in the parent folder. This is perfect for having a site structure like this:

app/js/
    templates/
        SoyToJsSrcCompiler.jar
        example.template.js
        js/templates/soyfiles/
            example.template.soy

Also, I recommend downloading SublimeOnSaveBuild (https://github.com/alexnj/SublimeOnSaveBuild) to automatically build your soy files on save. For this to work properly you will need to add ".soy" extensions to your package settings (https://github.com/alexnj/SublimeOnSaveBuild#configuring).

For syntax highlighting, add the package repository https://github.com/anvie/SoyTemplate and install SoyTemplate

For the required comment syntax snippets, install the DocBlockr package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment