You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/template-no-unnecessary-component-helper.md
+32-15Lines changed: 32 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,30 +6,47 @@
6
6
7
7
<!-- end auto-generated rule header -->
8
8
9
-
Disallow unnecessary usage of the `{{component}}` helper with static component names.
9
+
The `component` template helper can be used to dynamically pick the component being rendered based on the provided property. But if the component name is passed as a string because it's already known, then the component should be invoked directly, instead of using the `component` helper.
10
10
11
-
## Rule Details
11
+
## Examples
12
12
13
-
This rule disallows using `{{component "component-name"}}` when you could use angle bracket invocation instead.
13
+
This rule **forbids** the following:
14
14
15
-
## Examples
15
+
```gjs
16
+
<template>
17
+
{{component "my-component"}}
18
+
</template>
19
+
```
16
20
17
-
Examples of**incorrect**code for this rule:
21
+
This rule**allows**the following:
18
22
19
-
```hbs
20
-
{{component 'my-component'}}
21
-
{{component 'MyComponent' arg='value'}}
23
+
```gjs
24
+
<template>
25
+
{{component SOME_COMPONENT_NAME}}
26
+
</template>
22
27
```
23
28
24
-
Examples of **correct** code for this rule:
29
+
```gjs
30
+
<template>
31
+
{{!-- the `component` helper is needed to invoke this --}}
0 commit comments