dpinol / closure-templates

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

Renaming the property "default" #70

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Create the following template:

    /**
     * @param test
     */
    {template .template}
        <div>{$test.a.b.default.c.d}</div>
    {/template}

2. Compile it with SoyToJsSrcCompiler.

What is the expected output? What do you see instead?

I see:

    /**
     * @param {Object.<string, *>=} opt_data
     * @param {(null|undefined)=} opt_ignored
     * @return {string}
     * @notypecheck
     */
    test.template = function(opt_data, opt_ignored) {
      return '<div>' + soy.$$escapeHtml(opt_data.test.a.b['default'].c.d) + '</div>';
    };

The problem is this:

- SoyToJsSrcCompiler generates ['default']
- Closure Compiler, if it sees b.default in the source code, renames "default" 
to something else.
- When combining the output of SoyToJsSrcCompiler with some other code that 
uses a.b.default, the Closure Compiler will generate non-working code.

I would expect that either:

- The compiler issues an error or warning when seeing a.b.default
- The compiler does not rename "default" from a.b.default
- SoyToJsSrcCompiler generates a.b.default instead of a.b['default']

(or any other solution that would not break the resulting compiled code)

Original issue reported on code.google.com by radu.din...@gmail.com on 17 Apr 2013 at 3:52

GoogleCodeExporter commented 8 years ago
The Closure Compiler in ECMAScript 3 mode issues an error when seeing 
a.b.default. In 5, if not using advanced optimizations, it quotes default. In 
5, with advanced optimizations, it renames default. I see that it doesn't 
rename things like id or filters though... It should probably just leave 
default as is as well. Either that (in which case this would be related to the 
compiler), or the templates should probably understand ECMAScript 5.

Original comment by radu.din...@gmail.com on 17 Apr 2013 at 4:02

GoogleCodeExporter commented 8 years ago
Closure Templates has migrated to GitHub, 
https://gitub.com/google/closure-templates. Please reopen this there if it's 
still an issue.

Original comment by brendan....@gmail.com on 27 Feb 2015 at 12:01