diff --git a/documents/component.md b/documents/component.md
index 7e1f8a0..89aff7c 100644
--- a/documents/component.md
+++ b/documents/component.md
@@ -4,14 +4,14 @@ root: "."
output: "**/*"
---
-# {{inputs.typescript ? "!" : (inputs.classBased ? "!" : "")}}{{inputs.name.kebab}}.gjs
+# {{inputs.typescript ? "!" : (inputs.classBased ? "!" : "")}}{{inputs.name.path}}.gjs
```gjs
{{"{{"}}yield{{"}}"}}
```
-# {{inputs.typescript ? "!" : (inputs.classBased ? "" : "!")}}{{inputs.name.kebab}}.gjs
+# {{inputs.typescript ? "!" : (inputs.classBased ? "" : "!")}}{{inputs.name.path}}.gjs
```gjs
import Component from "@glimmer/component";
@@ -22,7 +22,7 @@ export default class {{inputs.name.pascal}} extends Component {
```
-# {{inputs.typescript ? (inputs.classBased ? "!" : "") : "!"}}{{inputs.name.kebab}}.gts
+# {{inputs.typescript ? (inputs.classBased ? "!" : "") : "!"}}{{inputs.name.path}}.gts
```gts
import type { TOC } from '@ember/component/template-only';
@@ -41,7 +41,7 @@ export default {{inputs.name.pascal}};
```
-# {{inputs.typescript ? (inputs.classBased ? "" : "!") : "!"}}{{inputs.name.kebab}}.gts
+# {{inputs.typescript ? (inputs.classBased ? "" : "!") : "!"}}{{inputs.name.path}}.gts
```gts
import Component from "@glimmer/component";
diff --git a/documents/helper.md b/documents/helper.md
index a03be14..541e9c4 100644
--- a/documents/helper.md
+++ b/documents/helper.md
@@ -4,7 +4,7 @@ root: "."
output: "**/*"
---
-# {{inputs.typescript ? "!" : (inputs.classBased ? "!" : "")}}{{inputs.name.kebab}}.js
+# {{inputs.typescript ? "!" : (inputs.classBased ? "!" : "")}}{{inputs.name.path}}.js
```js
import { helper } from "@ember/component/helper";
@@ -15,7 +15,7 @@ export default helper(function {{inputs.name.camel}}(positional, named) {
```
-# {{inputs.typescript ? "!" : (inputs.classBased ? "" : "!")}}{{inputs.name.kebab}}.js
+# {{inputs.typescript ? "!" : (inputs.classBased ? "" : "!")}}{{inputs.name.path}}.js
```js
import Helper from "@ember/component/helper";
@@ -28,7 +28,7 @@ export default class {{inputs.name.pascal}} extends Helper {
```
-# {{inputs.typescript ? (inputs.classBased ? "!" : "") : "!"}}{{inputs.name.kebab}}.ts
+# {{inputs.typescript ? (inputs.classBased ? "!" : "") : "!"}}{{inputs.name.path}}.ts
```ts
import { helper } from "@ember/component/helper";
@@ -51,7 +51,7 @@ export default helper<{{inputs.signature}}>(function {{inputs.name.camel}}(posit
```
-# {{inputs.typescript ? (inputs.classBased ? "" : "!") : "!"}}{{inputs.name.kebab}}.ts
+# {{inputs.typescript ? (inputs.classBased ? "" : "!") : "!"}}{{inputs.name.path}}.ts
```ts
import Helper from "@ember/component/helper";
diff --git a/documents/modifier.md b/documents/modifier.md
index bb114fa..b6cb554 100644
--- a/documents/modifier.md
+++ b/documents/modifier.md
@@ -4,7 +4,7 @@ root: "."
output: "**/*"
---
-# {{inputs.typescript ? "!" : (inputs.classBased ? "!" : "")}}{{inputs.name.kebab}}.js
+# {{inputs.typescript ? "!" : (inputs.classBased ? "!" : "")}}{{inputs.name.path}}.js
```js
import { modifier } from "ember-modifier";
@@ -13,7 +13,7 @@ export default modifier(function {{inputs.name.camel}}(element, positional, name
```
-# {{inputs.typescript ? "!" : (inputs.classBased ? "" : "!")}}{{inputs.name.kebab}}.js
+# {{inputs.typescript ? "!" : (inputs.classBased ? "" : "!")}}{{inputs.name.path}}.js
```js
import Modifier from "ember-modifier";
@@ -24,7 +24,7 @@ export default class {{inputs.name.pascal}} extends Modifier {
```
-# {{inputs.typescript ? (inputs.classBased ? "!" : "") : "!"}}{{inputs.name.kebab}}.ts
+# {{inputs.typescript ? (inputs.classBased ? "!" : "") : "!"}}{{inputs.name.path}}.ts
```ts
import { modifier } from "ember-modifier";
@@ -41,7 +41,7 @@ export default modifier<{{inputs.signature}}>(function {{inputs.name.camel}}(ele
```
-# {{inputs.typescript ? (inputs.classBased ? "" : "!") : "!"}}{{inputs.name.kebab}}.ts
+# {{inputs.typescript ? (inputs.classBased ? "" : "!") : "!"}}{{inputs.name.path}}.ts
```ts
import Modifier from "ember-modifier";
diff --git a/documents/service.md b/documents/service.md
index f0dc0db..79533f0 100644
--- a/documents/service.md
+++ b/documents/service.md
@@ -4,7 +4,7 @@ root: "."
output: "**/*"
---
-# {{inputs.name.kebab}}.{{inputs.typescript ? "ts" : "js"}}
+# {{inputs.name.path}}.{{inputs.typescript ? "ts" : "js"}}
```ts
import Service from "@ember/service";
@@ -13,7 +13,7 @@ export default class {{inputs.name.pascal}} extends Service {}
{{if inputs.typescript}}
declare module "@ember/service" {
interface Registry {
- "{{inputs.name.kebab}}": {{inputs.name.pascal}};
+ "{{inputs.name.path}}": {{inputs.name.pascal}};
}
}
{{end}}
diff --git a/src/generate-document.ts b/src/generate-document.ts
index ff3c464..20c4390 100644
--- a/src/generate-document.ts
+++ b/src/generate-document.ts
@@ -38,6 +38,10 @@ export async function generateDocument(
camel: camelCase(entityName),
kebab: kebabCase(entityName),
pascal: pascalCase(entityName),
+ path: entityName
+ .split("/")
+ .map((part) => kebabCase(part))
+ .join("/"),
raw: entityName,
},
signature: pascalCase(entityName) + "Signature",
diff --git a/test/__snapshots__/generate-component.test.ts.snap b/test/__snapshots__/generate-component.test.ts.snap
index d07bcb3..8fad2a0 100644
--- a/test/__snapshots__/generate-component.test.ts.snap
+++ b/test/__snapshots__/generate-component.test.ts.snap
@@ -28,6 +28,11 @@ export default class Foo extends Component {
"
`;
+exports[`generates a nested template-only \`.gjs\` component 1`] = `
+"{{yield}}
+"
+`;
+
exports[`generates a template-only \`.gjs\` component 1`] = `
"{{yield}}
"
diff --git a/test/__snapshots__/generate-helper.test.ts.snap b/test/__snapshots__/generate-helper.test.ts.snap
index 14d96b0..574409b 100644
--- a/test/__snapshots__/generate-helper.test.ts.snap
+++ b/test/__snapshots__/generate-helper.test.ts.snap
@@ -93,3 +93,12 @@ export default helper(function foo(positional, named) {
});
"
`;
+
+exports[`generates a nested function-based \`.js\` helper 1`] = `
+"import { helper } from "@ember/component/helper";
+
+export default helper(function fooBar(positional, named) {
+ return positional;
+});
+"
+`;
diff --git a/test/__snapshots__/generate-modifier.test.ts.snap b/test/__snapshots__/generate-modifier.test.ts.snap
index 6f28e77..696e18a 100644
--- a/test/__snapshots__/generate-modifier.test.ts.snap
+++ b/test/__snapshots__/generate-modifier.test.ts.snap
@@ -73,3 +73,10 @@ export interface FooSignature {
export default modifier(function foo(element, positional, named) {});
"
`;
+
+exports[`generates a nested function-based \`.js\` modifier 1`] = `
+"import { modifier } from "ember-modifier";
+
+export default modifier(function fooBar(element, positional, named) {});
+"
+`;
diff --git a/test/__snapshots__/generate-service.test.ts.snap b/test/__snapshots__/generate-service.test.ts.snap
index 17f29f4..b8bd441 100644
--- a/test/__snapshots__/generate-service.test.ts.snap
+++ b/test/__snapshots__/generate-service.test.ts.snap
@@ -39,3 +39,10 @@ declare module "@ember/service" {
}
"
`;
+
+exports[`generates a nested \`.js\` service 1`] = `
+"import Service from "@ember/service";
+
+export default class FooBar extends Service {}
+"
+`;
diff --git a/test/generate-component.test.ts b/test/generate-component.test.ts
index d6e2239..cf5fd39 100644
--- a/test/generate-component.test.ts
+++ b/test/generate-component.test.ts
@@ -72,3 +72,16 @@ it("generates a template-only `.gts` component at a custom path", async (ctx) =>
ctx.expect(content).toMatchSnapshot();
});
+
+it("generates a nested template-only `.gjs` component", async (ctx) => {
+ cwd = await copyBlueprint("v2-addon");
+
+ await generateComponent("foo/bar", { cwd });
+
+ const content = await readFile(
+ join(cwd, "src/components/foo/bar.gjs"),
+ "utf-8",
+ );
+
+ ctx.expect(content).toMatchSnapshot();
+});
diff --git a/test/generate-helper.test.ts b/test/generate-helper.test.ts
index 0ce979b..88e0ef3 100644
--- a/test/generate-helper.test.ts
+++ b/test/generate-helper.test.ts
@@ -72,3 +72,13 @@ it("generates a function-based `.ts` helper at a custom path", async (ctx) => {
ctx.expect(content).toMatchSnapshot();
});
+
+it("generates a nested function-based `.js` helper", async (ctx) => {
+ cwd = await copyBlueprint("v2-addon");
+
+ await generateHelper("foo/bar", { cwd });
+
+ const content = await readFile(join(cwd, "src/helpers/foo/bar.js"), "utf-8");
+
+ ctx.expect(content).toMatchSnapshot();
+});
diff --git a/test/generate-modifier.test.ts b/test/generate-modifier.test.ts
index 3486fa5..2dcef20 100644
--- a/test/generate-modifier.test.ts
+++ b/test/generate-modifier.test.ts
@@ -72,3 +72,16 @@ it("generates a function-based `.ts` modifier at a custom path", async (ctx) =>
ctx.expect(content).toMatchSnapshot();
});
+
+it("generates a nested function-based `.js` modifier", async (ctx) => {
+ cwd = await copyBlueprint("v2-addon");
+
+ await generateModifier("foo/bar", { cwd });
+
+ const content = await readFile(
+ join(cwd, "src/modifiers/foo/bar.js"),
+ "utf-8",
+ );
+
+ ctx.expect(content).toMatchSnapshot();
+});
diff --git a/test/generate-service.test.ts b/test/generate-service.test.ts
index 538dad5..d86da62 100644
--- a/test/generate-service.test.ts
+++ b/test/generate-service.test.ts
@@ -48,3 +48,13 @@ it("generates a `.ts` service at a custom path", async (ctx) => {
ctx.expect(content).toMatchSnapshot();
});
+
+it("generates a nested `.js` service", async (ctx) => {
+ cwd = await copyBlueprint("v2-addon");
+
+ await generateService("foo/bar", { cwd });
+
+ const content = await readFile(join(cwd, "src/services/foo/bar.js"), "utf-8");
+
+ ctx.expect(content).toMatchSnapshot();
+});