Skip to content

Commit

Permalink
Merge pull request #44 from Medium/nick-ijdata
Browse files Browse the repository at this point in the history
turn on --isUsingIjData by default
  • Loading branch information
nicks committed Mar 3, 2015
2 parents 1f29d2a + c7a9783 commit 55b6ffb
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/SoyCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ SoyCompiler.prototype._compileTemplateFilesAndEmit = function (inputDir, files,
args.push('--shouldDeclareTopLevelNamespaces', 'false');
}

// Always turn on isUsingIjData.
// https://groups.google.com/forum/#!topic/closure-templates-discuss/8rxD9I0QrtI
args.push('--isUsingIjData')

args.push('--outputPathFormat', outputPathFormat)

// Execute the comamnd inside the input directory.
Expand Down
6 changes: 6 additions & 0 deletions lib/SoyOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ function SoyOptions() {
* @type {boolean}
*/
this.shouldDeclareTopLevelNamespaces = true

/**
* Indicates that $ij variables are used and should be passed between templates.
* @type {boolean}
*/
this.isUsingIjData = false
}


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "soynode",
"version" : "0.7.3",
"version" : "0.7.4",
"description" : "Utility for working with Closure Templates, aka Soy, from within a node.js application.",
"keywords" : ["node", "soy", "templates", "closure"],
"repository" : {
Expand Down
8 changes: 8 additions & 0 deletions test/assets/template2.soy
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@
**/
{template .formletter}
{msg desc="Promotional message for ordering theme songs"}Dear {$title} {$surname}: With a name like {$title} {$surname}, shouldn't you have your own theme song? We can help!{/msg}
{/template}

/**
* @param title
* @param surname
**/
{template .formletterCall}
{call template1.formletter data="all" /}
{/template}
15 changes: 15 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ module.exports = {
var contents = fs.readFileSync(soyJsFilePath, 'utf8');
test.equal(-1, contents.indexOf('var template1 ='));

test.done();
});
},

testWithIjData: function(test) {
soynode.setOptions({
uniqueDir: false
});
soynode.compileTemplateFiles([__dirname + '/assets/template1.soy', __dirname + '/assets/template2.soy'], function(err) {
test.ifError(err);

var soyJsFilePath = path.join('/tmp/soynode', __dirname, 'assets/template2.soy.js');
var contents = fs.readFileSync(soyJsFilePath, 'utf8');
test.notEqual(-1, contents.indexOf('template1.formletter(opt_data, null, opt_ijData)'));

test.done();
});
}
Expand Down

0 comments on commit 55b6ffb

Please sign in to comment.