Skip to content

Commit

Permalink
Merge pull request #56 from davidtaylorhq/nested-components
Browse files Browse the repository at this point in the history
Fix support for nested components in mustache statement
  • Loading branch information
chancancode committed Oct 17, 2023
2 parents fa64164 + ee666e5 commit 2b610a4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/helpers/string.ts
Expand Up @@ -19,5 +19,7 @@ export function squish(str: string): string {
}

export function classify(str: string): string {
return upperFirst(camelCase(str));
const parts = str.split('/');
const classifiedParts = parts.map((p) => upperFirst(camelCase(p)));
return classifiedParts.join('::');
}
@@ -0,0 +1,3 @@
<div ...attributes data-test-global-component>
nested-global-component-contents
</div>
14 changes: 14 additions & 0 deletions tests/dummy/app/components/somedir/nested-global-component.ts
@@ -0,0 +1,14 @@
import Component from '@glimmer/component';

interface GlobalComponentSignature<Arg = string | undefined> {
Element: HTMLDivElement;
}

// eslint-disable-next-line ember/no-empty-glimmer-component-classes
export default class NestedGlobalComponent extends Component<GlobalComponentSignature> {}

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'somedir/nested-global-component': typeof NestedGlobalComponent;
}
}
5 changes: 5 additions & 0 deletions tests/integration/plugin/mustache-statement-test.ts
Expand Up @@ -28,6 +28,11 @@ module('Integration | Plugin | MustacheStatement', function (hooks) {
assert.dom().hasText('global-component-contents');
});

test('handles a nested invocable component', async function (assert) {
await render(hbs`{{somedir/nested-global-component}}`);
assert.dom().hasText('nested-global-component-contents');
});

test('does nothing to an invocable modifier', async function (assert) {
await render(hbs`<div {{global-modifier}} />`);
assert.dom().hasText('global-modifier-result');
Expand Down

0 comments on commit 2b610a4

Please sign in to comment.