deprecate / gulp-soynode Goto Github PK
View Code? Open in Web Editor NEWGulp plugin using soynode for working with Closure Templates, aka Soy.
Gulp plugin using soynode for working with Closure Templates, aka Soy.
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.
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.
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?
"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)
c:\tmp\soynode
has a views
folder - not a build
folder which it appear to try to read from..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.tmp
folder in the root of C:
.Any ideas why the example yields errors?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.