Need private packages and team management tools?Check out npm Orgs. »


2.0.0 • Public • Published

gulp-soynode Build Status

Gulp plugin using soynode for working with Closure Templates, aka Soy.

Issues with the output should be reported on the soynode issue tracker.


$ npm install --save-dev gulp-soynode


var gulp = require('gulp');
var soynode = require('gulp-soynode');
gulp.task('build', function() {
  return gulp.src('views/*.soy')

You can also watch for changes to rebuild all templates:

gulp.task('watch', function(done) {'views/*.soy', ['build']);

Or, if you prefer, rebuild only one the modified file:

gulp.task('watch', function(done) {'test/*.soy', function(file) {

Message extraction

You can also use gulp-soynode to extract all messages from your soy templates into a tlf file, which can be used for translating them later. To use it, just call soynode.lang with the name of the file you want the messages to be extracted to:

var gulp = require('gulp');
var soynode = require('gulp-soynode');
gulp.task('build-lang', function() {
  return gulp.src('views/*.soy')
      outputFile: 'translations/translations_en.xlf'

Build with locales

var gulp = require('gulp');
var soynode = require('gulp-soynode');
gulp.task('build', function() {
  return gulp.src('views/*.soy')
      locales: ['en', 'pt-BR'],
        messageFilePathFormat: 'translations/translations_{LOCALE}.xlf'



Options can be set via soynode(options), the keys can contain the following:

  • renderSoyWeb {boolean} Whether SoyWeb templates will be rendered automatically. It deliberately allows to includes dummy data so the designer can get a feel for how the task list will appear with real data rather with minimal copy and paste. For more information visit [Default: false]
  • renderSoyWebContext {Object|function()} Default render context of rendered SoyWeb file, or a function that is called with each handled file, returning the context object for it. [Default: null]
  • renderSoyWebFileExtension {string} File extension of the rendered SoyWeb file. Relevant when your Soy template outputs other formats, like .md. [Default: .html]
  • renderSoyWebInjectedData {Object|function()} Object with injected data to be used when rendering SoyWeb files, or a function that is called with each handled file, returning the injected data for it. [Default: null]
  • inputDir {string} Optional path to a directory where files will be read. When compiled from a directory, this option will be overwritten with the caller inputDir. [Default: process.cwd()]
  • outputDir {string} Path to a directory where files will be written. [Default: null]
  • eraseTemporaryFiles {boolean} Whether to erase temporary files after a compilation. [Default: false]
  • concatOutput {boolean} Whether the compiled soy.js files should be joined into a single file. This is helpful for loading templates in a browser and simplest to use when outputDir is explicitly set and uniqueDir is false. [Default: false]
  • concatFileName {string} File name used for concatenated files, only relevant when concatOutput is true, ".soy.concat.js" is appended, so don't include ".js" yourself. [Default: compiled]
  • locales {Array} List of locales to translate the templates to.
  • messageFilePathFormat {string} Path to the translation file to use, which can contain any of the placeholders allowed on the --messageFilePathFormat option of SoyToJsSrcCompiler.jar.

See the soynode options for more information.


Options can be set via soynode.lang(options), the keys can contain the following:

  • outputFile {String} The path of the file with the resulting extracted messages. [Default: '/tmp/soynode/translations.xlf']


Questions, comments, bug reports, and pull requests are all welcome. Submit them at the project on GitHub.

Bug reports that include steps-to-reproduce (including code) are the best. Even better, make them in the form of pull requests.


MIT © Eduardo Lundgren


Eduardo Lundgren (personal website).


npm i gulp-soynode

Downloadsweekly downloads









last publish


  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability