Skip to content

Loosen restrictions around component argument names #803

@bertdeblock

Description

@bertdeblock

At the moment, only argument names starting with a lowercase letter are allowed.
I think it would be nice if this restriction could be loosened for the following use cases:

  1. Argument names starting with an uppercase letter (passing along a component via an argument to another component):
<Foo @Bar={{component "bar"}} />
{{! foo.hbs }}
<@Bar />

The PascalCase argument name makes it clearer that we are passing along a component,
and is also inline with how the component is normally invoked (<Bar />).

  1. Argument names starting with an underscore (passing along a "private" argument from a parent component to a child component):
{{! parent.hbs }}
{{yield (hash Child=(component "child" _foo="bar"))}}
{{! child.hbs }}
{{@_foo}}

The underscore makes it clearer that this argument can only come from its parent,
and is not meant to be used publicly when invoking the child component.

Both cases also work in JS land:

  • this.args.Bar
  • this.args._foo

Mainly opening this issue to see if other people think this is a good idea,
and to see if other uses cases are missing.

Totally up for writing the RFC myself if this turns out to be a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions