Ember.js: Passing 'view' as a parameter to a component causes build error

Created on 9 Mar 2016  路  8Comments  路  Source: emberjs/ember.js

When passing arguments to a component, if one of the parameters is named 'view' ember falsely generates a build error.

The Broccoli Plugin: [TemplateCompiler] failed with:
Error: Assertion Failed: Using `{{view}}` or any path based on it ('otainsight-ember/pods/rates/template.hbs' @ L12:C20) has been removed in Ember 2.0
    at new Error (native)
    at Error.EmberError (/bower_components/ember/ember-template-compiler.js:4525:21)
    at assert (/bower_components/ember/ember-template-compiler.js:1387:13)
    at Object.assert (/bower_components/ember/ember-template-compiler.js:4289:34)
    at assertPath (/bower_components/ember/ember-template-compiler.js:11857:22)
    at assertPaths (/bower_components/ember/ember-template-compiler.js:11852:7)
    at assertHash (/bower_components/ember/ember-template-compiler.js:11841:7)
    at /bower_components/ember/ember-template-compiler.js:11827:7
    at Walker.visit (/bower_components/ember/ember-template-compiler.js:18766:7)
    at visitors.ElementNode (/bower_components/ember/ember-template-compiler.js:18782:16)

The broccoli plugin was instantiated at:
    at TemplateCompiler.Plugin (/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/node_modules/broccoli-plugin/index.js:7:31)
    at TemplateCompiler.Filter [as constructor] (/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/index.js:38:10)
    at new TemplateCompiler (/node_modules/ember-cli-htmlbars/index.js:20:10)
    at TemplateCompiler (/node_modules/ember-cli-htmlbars/index.js:12:12)
    at Object.registry.add.toTree (/node_modules/ember-cli-htmlbars/ember-addon-main.js:32:16)
    at /node_modules/ember-cli/node_modules/ember-cli-preprocess-registry/preprocessors.js:184:26
    at Array.forEach (native)
    at processPlugins (/node_modules/ember-cli/node_modules/ember-cli-preprocess-registry/preprocessors.js:182:11)
    at module.exports.preprocessTemplates (/node_modules/ember-cli/node_modules/ember-cli-preprocess-registry/preprocessors.js:165:10)
    at EmberApp._processedTemplatesTree (/node_modules/ember-cli/lib/broccoli/ember-app.js:750:48)

This can easily be reproduced in Ember 2.4, the following line generates the error:
{{selections-view activeView=view availableViews=availableViews exportAction='export'}}
while the following doesn't:
{{selections-view activeView='calendar' availableViews=availableViews exportAction='export'}}

The commit that added these checks can be found here, but I believe this case is a false positive? I don't see any reason why you shouldn't be allowed to use 'view' as a param.

Most helpful comment

@rwjblue Much appreciated. Thanks for being so helpful and responsive! Open source devs don't get enough love, so 鉂わ笍

All 8 comments

In Ember 1.x {{view}} or {{foo-bar blah=view}} had special/specific meaning that was deprecated in Ember 1.13 and removed in Ember 2.0. We added this error in order to provide a reasonable experience to users upgrading from Ember 1.13 to Ember 2.0.

Conceptually, using a view property on a component/controller/etc for something _other_ than its prior usage is likely to be very confusing and is better to be avoided.

This isn't really a bug per-se (it is intended behavior), but it is something we should keep in mind when we drop support for the ember-legacy-views addon we can also remove this assertion.

@rwjblue I'm getting the same error on our CI server despite having ember-legacy-views installed. Any suggestions?

@mfeckie - Most likely this is due to https://github.com/ember-cli/ember-cli-htmlbars/issues/71.

@rwjblue Interesting! Our htmlbars is pinned at '^1.0.3' too .

OK, I just released [email protected] with that change reverted for now. Didn't want to leave folks in a bad state while I track down the issue...

Related to the originally reported issue, I am going to have to close this. We have to keep the current assertion around until at least 2.8 (to help folks that are migrating off the ember-legacy-views addon identify the locations they are using view paths in their templates).

@rwjblue Much appreciated. Thanks for being so helpful and responsive! Open source devs don't get enough love, so 鉂わ笍

Was this page helpful?
0 / 5 - 0 ratings