Skip to content

Latest commit

 

History

History
57 lines (38 loc) · 1.62 KB

File metadata and controls

57 lines (38 loc) · 1.62 KB

ember/template-no-model-argument-in-route-templates

🔧 This rule is automatically fixable by the --fix CLI option.

HBS Only: This rule applies to classic .hbs template files only (loose mode). It is not relevant for gjs/gts files (strict mode), where these patterns cannot occur.

In Ember route templates, the model should be accessed via this.model in the controller or component, not as an @model argument. The @model argument pattern is more appropriate for components. This rule primarily targets .hbs files in the templates/ directory.

Rule Details

This rule disallows the use of @model argument in route templates (.hbs files in templates/ directory).

Examples

Examples of incorrect code for this rule (in route templates):

<!-- app/templates/index.hbs -->
{{@model}}
<!-- app/templates/users.hbs -->
{{@model.name}}
<!-- app/templates/posts/show.hbs -->
{{@model.id}}

Examples of correct code for this rule:

<!-- app/templates/index.hbs -->
{{this.model}}
// app/components/user-card.gjs
{{@model.name}}
{{this.model}}

Migration

This rule includes a fixer in order to handle the migration for you automatically.

References