DEV: introduce <template> tag support (.gjs)#21899
Closed
chancancode wants to merge 9 commits intodiscourse:mainfrom
Closed
DEV: introduce <template> tag support (.gjs)#21899chancancode wants to merge 9 commits intodiscourse:mainfrom
<template> tag support (.gjs)#21899chancancode wants to merge 9 commits intodiscourse:mainfrom
Conversation
chancancode
commented
Jun 1, 2023
chancancode
commented
Jun 1, 2023
app/assets/javascripts/discourse-common/addon/helpers/html-safe.js
Outdated
Show resolved
Hide resolved
chancancode
commented
Jun 1, 2023
app/assets/javascripts/discourse-common/addon/helpers/d-icon.js
Outdated
Show resolved
Hide resolved
chancancode
commented
Jun 2, 2023
Contributor
Author
There was a problem hiding this comment.
If you click View file you can preview the half-baked syntax highlighting (the JS stuff is fine, the <template> tag is somewhat working due to JSX support). It's probably not working here on the PR because it needs to be merged into main to fully take effect? (It's a guess, but @gitKrystan said she'd seen the same thing elsewhere)
chancancode
commented
Jun 2, 2023
c7198c9 to
4e7006f
Compare
Contributor
Author
ec5710b to
9910085
Compare
Contributor
Author
|
@cvx updated with the latest ESLint stuff and added |
This enables support for .gjs files in the build Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
* Add missing `truth-helpers` dependencies This addon is in the workspace but not explicitly referenced in package.json (should it be in devDependencies?) * Export helpers from `d-icon` in discourse-common In order to use helpers in `<template>` they need to be imported. Not sure what's the semantics of the `registerUnbound` internal helper and if this refactor changed anything important. Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
This tells GitHub to use js/ts mode for gjs/gts syntax highlighting, which is hopefully better than nothing? Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
This adds Glint to the project in JS mode (as opposed to TS). This brings back the basic JS language server support in .gjs files in VSCode (if you have the Glint extension installed). For other editors, it should be possible to integrate directly via the `glint-language-server` executable. Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
Change the sample vscode settings: extensions.json – this "recommends" the appropriate VSCode extensions for use with .gjs development settings.json – this sets the default formatter for .gjs files (without this setting the user will be prompted to select one the first time), also sets up the ESLint extension to check .gjs files. Note that – the .vscode-sample directory doesn't do anything by itself. These changes need to be pulled into your local `.vscode` directory. Added the `.vscode` directory to `.gitignore` for now, but feel free to improve on that setup. Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
Co-authored-by: Krystan HuffMenne <kmenne+github@gmail.com>
<template> (.gjs) tag support (.gjs`)
tag support (.gjs`)<template> tag support (.gjs)
Member
|
Landed via #22719 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is intended to be a starting point for a conversation/playground, where the Discourse team members can checkout the branch and play with it to evaluate whether this is something we want to start adopting at this stage.
Some notable things:
Because it's a new file extension, some configurations is needed for editor and tooling support. This PR includes what's necessary for VSCode as well as the CLI stuff used in the project (e.g. prettier).
Template tags do not support "global resolutions" so everything needs to be imported. This may require some refactoring and/or boilerplate code for some existing code (the PR includes example changes to the d-icon and html-safe helpers used by
<DButton>). Note that some of the boilerplate is somewhat offset by the ability to invoke plain JS functions from within the template (Ember 4.5+, or polyfill available).This also sets up Glint (https://typed-ember.gitbook.io/glint/) to get back the basic language server support, but also sets the stage for more adoption down the road (either with more rigorous JSDoc or TypeScript).
TODO: check eslint support.For prosperity, here is the same information but in the form of a rap song: