Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 1.66 KB

File metadata and controls

63 lines (44 loc) · 1.66 KB

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

💼 This rule is enabled in the following configs: strict-gjs, strict-gts.

✅ The extends: 'plugin:ember/strict-gjs' or extends: 'plugin:ember/strict-gts' property in a configuration file enables this rule.

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
<template>
  {{@model.name}}
</template>
<template>
  {{this.model}}
</template>

References

  • strictGjs: true
  • strictGts: true