npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-soynode

v2.0.0

Published

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

Downloads

97

Readme

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.

Install

$ npm install --save-dev gulp-soynode

Usage

var gulp = require('gulp');
var soynode = require('gulp-soynode');

gulp.task('build', function() {
  return gulp.src('views/*.soy')
    .pipe(soynode())
    .pipe(gulp.dest('build'));
});

You can also watch for changes to rebuild all templates:

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

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

gulp.task('watch', function(done) {
  gulp.watch('test/*.soy', function(file) {
    gulp.src(file.path)
      .pipe(soynode())
      .pipe(gulp.dest('build'));
  });
});

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')
    .pipe(soynode.lang({
      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')
    .pipe(soynode({
      locales: ['en', 'pt-BR'],
        messageFilePathFormat: 'translations/translations_{LOCALE}.xlf'
    }))
    .pipe(gulp.dest('build'));
});

API

soynode(options)

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 http://plovr.com/soyweb.html. [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.

soynode.lang(options)

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']

Contributing

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.

License

MIT © Eduardo Lundgren

Author

Eduardo Lundgren (personal website).