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

Add support for Glimmer JS and Glimmer TS #1022

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,20 @@
"quotes": [["\\\"", "\\\""]],
"extensions": ["gleam"]
},
"GlimmerJs": {
"name": "Glimmer JS",
"multi_line_comments": [["<!--", "-->"], ["{{!", "}}"], ["/*", "*/"]],
"quotes": [["\\\"", "\\\""], ["'", "'"], ["`", "`"]],
"extensions": ["gjs"],
"line_comment": ["//"]
},
"GlimmerTs": {
"name": "Glimmer TS",
"multi_line_comments": [["<!--", "-->"], ["{{!", "}}"], ["/*", "*/"]],
"quotes": [["\\\"", "\\\""], ["'", "'"], ["`", "`"]],
"extensions": ["gts"],
"line_comment": ["//"]
},
"Glsl": {
"name": "GLSL",
"line_comment": ["//"],
Expand Down
29 changes: 29 additions & 0 deletions tests/data/glimmer_js.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 29 lines 17 code 6 comments 5 blanks

import Component from '@glimmer/component';

/**
* @param bar - a thing
*/
function foo(bar) {
console.log(bar); // we foo'd the bar
}

const Greet = <template>
{{! a Handlebars comment in the template }}
<div>A template!</div>
<!-- an HTML comment in the template -->
<p>{{@greeting}}</p>
</template>;

class Example extends Component {
get greeting() {
// counts
return `Hello, ${this.args.name}`; // does not count
}

<template>
<Greet @greeting={{this.greeting}} /> {{! with an HBS comment }}
<div>{{yield @extra}}</div> <!-- with an HTML comment -->
</template>
}
47 changes: 47 additions & 0 deletions tests/data/glimmer_ts.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 47 lines 31 code 9 comments 6 blanks

import Component from '@glimmer/component';
import type { TOC } from '@ember/component/template-only';

/**
* @param bar - a thing
*/
function foo(bar: string): void {
console.log(bar); // we foo'd the bar
}

const Greet: TOC<{
Args: {
/** the greeting to show */
greeting: string;
};
}> = <template>
{{! a Handlebars comment in the template }}
<div>A template!</div>
<!-- an HTML comment in the template -->
<p>{{@greeting}}</p>
</template>;

interface ExampleSig<T> {
Args: {
/** The name of the person to greet */
name: string;
/** Extra info to pass along */
extra: T;
};
Blocks: {
default: [T];
};
}

class Example extends Component<CommonSig> {
get greeting() {
// counts
return `Hello, ${this.args.name}`; // does not count
}

<template>
<Greet @greeting={{this.greeting}} /> {{! with an HBS comment }}
<div>{{yield @extra}}</div> <!-- with an HTML comment -->
</template>
}