Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for nested components in mustache statement #56

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/helpers/string.ts
Original file line number Diff line number Diff line change
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('::');
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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