caofangkun / closure-templates

Automatically exported from code.google.com/p/closure-templates
Apache License 2.0
0 stars 0 forks source link

Conditional inclusion of injected data incorrect for cross-namespace references #51

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a 'common' .soy file containing templates that rely on injected data
2. Create a 'mypage' .soy file containing templates rendering the html shell 
and relying on 'common' templates but without using $ij data themselves
3. Execute the SoyJsSrcCompiler compilation

What is the expected output? What do you see instead?
Expected: The generated template methods include the opt_ijdata parameter 
allowing injected data to be passed from custom JS, which will be needed by the 
common templates
Actual: The JS generated from 'common' includes injected data; the JS generated 
from 'mypage' does not. This appears to be because the mypage soy tree does not 
use injected data.

What version of the product are you using? On what operating system?
version: 2011-14-10
o/s: Mac OS X

Please provide any additional information below:
I'm not sure whether the generation is being "smart" and determining whether 
the particular element of 'common' that 'mypage' called were using $ij 
themselves; I believe they were, but possibly not.

Either way, it would be preferable to let the project determine whether IJ data 
should be included in the parameter list globally (probably via a compiler 
option similar to the provides/requires option). Since injected data will be 
used by some templates, all template calls should habitually include a 
reference to the client-side injected data, without causing the closure 
compiler to complain that extra parameters are being passed to the template 
execution method (for the handful of templates that happen to not use it).

Original issue reported on code.google.com by matt.sch...@gmail.com on 27 Nov 2011 at 9:17

GoogleCodeExporter commented 8 years ago
Sorry for the very late response.

Are you compiling the 'common' and 'mypage' files together in one bundle, or 
are you compiling them in separate calls to SoyToJsSrcCompiler?

The compiler expects all Soy files to be compiled together at once. I believe 
the behavior you're seeing most likely is due to compiling them separately.

BTW, if you want to force the generation of opt_ijData, you can use the 
compiler flag --isUsingIjData.

I'm going to close this issue. Please feel free to reopen it if my reply is not 
correct for your situation, and you believe there is still a bug here. Thanks.

Original comment by kai.hu...@gmail.com on 20 Mar 2012 at 10:38