Giter Site home page Giter Site logo

gulp-soynode's People

Contributors

eduardolundgren avatar jbalsas avatar mairatma avatar matuzalemsteles avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gulp-soynode's Issues

Explain the translation features better

We've gotten feedback that it's not very clear how the translation feature works with soy and gulp-soy-node. Let's add an example explaining this better.

Allow soynode.render parameters to be functions that receive file buffer as argument

Currently this is how soynode.render receives arguments.

  var rendered = soynode.render(
    namespace + '.soyweb',
    optionsInternal.renderSoyWebContext,
    optionsInternal.renderSoyWebInjectedData,
    optionsSoynode.locales ? optionsSoynode.locales[0] : null
  );

It would be nice if renderSoyWebContext (and possibly the other args) could be a function that receives the file buffer as an argument and returns the value. That way you could do something like the following...

return gulp.src('src/**/*.soy', {
    .pipe(frontMatter())
    .pipe(soynode({
        renderSoyWeb: true,
        renderSoyWebContext: function(file) {
            return {
                frontMatter: file.frontMatter
            }
        }
    }))
    .pipe(gulp.dest('dist'));

This is a pattern I've seen with many other gulp plugins for templates, and it would nice to use here.

Doesn't respect concatOutput

I tried to use concatOutput and concatFileName to create a single concatenated output file. The temp folder will produce the file, but gulp-soynode will copy the individually compiled files.

I also tried to use gulp-concat on the stream but the just concatenated the source .soy files.

Is this not supported - or am I using it wrong?

Example gives build error

    "gulp": "^3.9.1",
    "gulp-soynode": "^1.5.1"

When I try to use the example from the description, after using the build-lang command to build the xlf file and generating a translated version:

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

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

I would get an error:

λ gulp build
[14:05:45] Using gulpfile ~\Desktop\gulp\gulpfile.js
[14:05:45] Starting 'build'...
[14:05:45] Finished 'build' after 18 ms
fs.js:549
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'C:\tmp\soynode\build\simple_de.soy.js'
    at Error (native)
    at Object.fs.openSync (fs.js:549:18)
    at Object.fs.readFileSync (fs.js:397:15)
    at C:\Users\tthomas2\Desktop\gulp\node_modules\gulp-soynode\index.js:129:24
    at Array.forEach (native)
    at C:\Users\tthomas2\Desktop\gulp\node_modules\gulp-soynode\index.js:121:15
    at Array.forEach (native)
    at EventEmitter.<anonymous> (C:\Users\tthomas2\Desktop\gulp\node_modules\gulp-soynode\index.js:118:11)
    at EventEmitter.g (events.js:260:16)
    at emitTwo (events.js:87:13)
  1. I notice that c:\tmp\soynode has a views folder - not a build folder which it appear to try to read from.
  2. If I change .pipe(gulp.dest('build')); to .pipe(gulp.dest('views')); then I get the js files copied back into my source view folder - which is not where I want them.
  3. I haven't been able to figure out how to control the location of the temp folder - I don't want gulp-soynode to create a tmp folder in the root of C:.

Any ideas why the example yields errors?

In some cases files fail to compile but no error is emitted

Say I have a .soy file with the following template and $results is not defined.

/**
 * @param? results
 */
{template .results}
	<div class="search-result-container">
		{foreach $result in $results}
			<span>{$result.title}</span>
		{/foreach}
	</div>
{/template}

The file will fail to compile but no errors are thrown notifying the developer that something has gone wrong.

If the template is fixed by checking for $results everything compiles fine.

/**
 * @param? results
 */
{template .results}
	<div class="search-result-container">
		{if $results}
			{foreach $result in $results}
				<span>{$result.title}</span>
			{/foreach}
		{/if}
	</div>
{/template}

It would be nice to know that one of my files failed to compile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.