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

Quest: First-Class Component Templates #33

Open
3 of 6 tasks
Tracked by #871
chriskrycho opened this issue Apr 21, 2022 · 7 comments
Open
3 of 6 tasks
Tracked by #871

Quest: First-Class Component Templates #33

chriskrycho opened this issue Apr 21, 2022 · 7 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@chriskrycho
Copy link

chriskrycho commented Apr 21, 2022

The path to making RFC emberjs/ember.js#779: First-Class Component Templates stable and recommended for end users.

What even is this?

Background

RFC emberjs/ember.js#779: First-Class Component Templates picked <template> tags as the the ability for Ember (and Glimmer) developers to write components with template tags embedded in their JS, like so:

import Component from '@glimmer/component';

const Button = <template>
  <button
    type='button'
    class="my-button"
    {{on "click" @onClick}}
  >
    {{@label}}
  </button>
</template>

export default class Player extends Component {
  @tracked isPlaying = false;

  play = () => (this.isPlaying = true);
  pause = () => (this.isPlaying = false);

  <template>
    <audio src={{@srcUrl}} {{playWhen this.isPlaying}} />

    <Button @label="Play" @onClick={{this.play}} />
    <Button @label="Pause" @onClick={{this.pause}} />
  </template>
}

This is not only a general win for ease of working with Ember: it is also a key part of our TypeScript story, because it makes things like go-to-definition, documentation hovers, autocomplete, auto-import, etc. all much easier to manage. So: what do we need to do to finish unblocking its adoption?

The Road to Stable

See ember-cli/ember-template-imports#35 for details on each part of this.

  • Prettier support
  • ESLint support
  • ember-template-lint integration

The Road to Recommended

  • Finish and publish specification
  • Make any spec-driven updates to ember-template-imports
  • Integrate ember-template-imports into Glimmer, with Ember being a customer
@chriskrycho chriskrycho added the help wanted Extra attention is needed label Apr 21, 2022
@chriskrycho
Copy link
Author

chriskrycho commented Nov 7, 2022

Thanks as well to @wycats, @bmish, and @rwjblue for helping get those various efforts across the line.

I’ll make sure we follow up on this in one of the next few Framework Core team meetings—this is amazing progress, and represents a huge step toward stabilizing this and eventually making it the recommended way of writing Ember templates.

(Keep your eyes open for code-mods coming soon™!)

@ef4
Copy link

ef4 commented Jul 20, 2023

A status update here is that

@wagenet
Copy link
Member

wagenet commented Aug 11, 2023

@ef4 Do we have an updated checklist on this?

@ef4
Copy link

ef4 commented Aug 28, 2023

  • publish a version of ember-cli-htmlbars that depends on a minimum babel-plugin-ember-template-compilation version of 2.2.0 and that adds the @babel/plugin-transform-class-static-block plugin whenever adding the other class-feature plugins that are implied by legacy decorators.
  • publish a version of embroider that depends on a minimum babel-plugin-ember-template-compilation version of 2.2.0 and that adds the @babel/plugin-transform-class-static-block plugin whenever adding the other class-feature plugins that are implied by legacy decorators.
  • publish a new ember-template-imports that uses content-tag to do preprocessing and does nothing on the babel side, documenting that it requires the above mentioned ember-cli-htmlbars or embroider version.
  • document clearly how to get full editor support (syntax highlighting, linters, typescript) when using template tag in (at least) VSCode.
  • ensure that the blueprints support prettier / eslint / etc of GJS/GTS out of the box.
  • update guides to use <template>

@NullVoxPopuli
Copy link

couple clarifying questions:

document

where to do this?
linting should be automatic provided new enough eslint-plugin-ember and ember-template-lint.

update guides to use

pre-polaris? if so, this would be a good thing to start soon, given all the implementation stuff is done? (this is a really big given.)
there is a bunch of infra-work for the ember-family-of-sites blocking this, afaik (empress, guide-maker, highlighting, (my prism PRs, etc))

@NullVoxPopuli
Copy link

NullVoxPopuli commented Jan 22, 2024

Remaining todos

Untracked / missing-GH-issue

Features

Compatibility

Docs

Readiness Progression

Highlighting

Linting

Requires eslint-plugin-ember @ v12+

Glint

Nice to have

@Windvis
Copy link

Windvis commented Sep 30, 2024

Adding support for generating .gjs/.gts components is also one of the remaining todos. There is an open PR already: emberjs/ember.js#20511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: In Progress
Development

No branches or pull requests

6 participants