Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.01 KB

File metadata and controls

51 lines (36 loc) · 1.01 KB

ember/template-no-unavailable-this

Disallow this in templates that are not inside a class or function.

Rule Details

In Ember and Glimmer, this refers to the component instance. When a <template> tag is used at module level (not inside a class body or function), this has no meaningful value and will be undefined. This rule catches accidental usage of this in such templates.

Examples

Examples of incorrect code for this rule:

<template>
  {{this.name}}
</template>
<template>
  {{yield this}}
</template>

Examples of correct code for this rule:

import Component from '@glimmer/component';

class MyComponent extends Component {
  <template>{{this.name}}</template>
}
function myComponent() {
  return <template>{{this.name}}</template>;
}
<template>
  {{@value}}
</template>

References