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/TS #1052

Open
wants to merge 5 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,22 @@
"quotes": [["\\\"", "\\\""]],
"extensions": ["gleam"]
},
"GlimmerJs": {
"name": "Glimmer JS",
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
"quotes": [["\\\"", "\\\""], ["'", "'"], ["`", "`"]],
"important_syntax": ["<template", "<style"],
"extensions": ["gjs"]
},
"GlimmerTs": {
"name": "Glimmer TS",
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
"quotes": [["\\\"", "\\\""], ["'", "'"], ["`", "`"]],
"important_syntax": ["<template", "<style"],
"extensions": ["gts"]
},
"Glsl": {
"name": "GLSL",
"line_comment": ["//"],
Expand Down
4 changes: 3 additions & 1 deletion src/language/embedding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ impl<'a> RegexCache<'a> {
LanguageType::Html
| LanguageType::RubyHtml
| LanguageType::Svelte
| LanguageType::Vue => {
| LanguageType::Vue
| LanguageType::GlimmerJs
| LanguageType::GlimmerTs => {
let html = HtmlLike {
start_script: save_captures(&START_SCRIPT, lines, start, end),
start_style: save_captures(&START_STYLE, lines, start, end),
Expand Down
26 changes: 26 additions & 0 deletions tests/data/glimmer-js.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 26 lines, 18 code, 4 comments, 4 blanks
import { helper } from '@ember/component/helper';
import { modifier } from 'ember-modifier';

// A single-line comment
const plusOne = helper(([num]) => num + 1);

/**
* A multi-line comment
*/
const setScrollPosition = modifier((element, [position]) => {
element.scrollTop = position
});

<template>
<div class="scroll-container" {{setScrollPosition @scrollPos}}>
{{#each @items as |item index|}}
Item #{{plusOne index}}: {{item}}
{{/each}}
</div>
<style>
div {
background-color: #E04E39;
}
</style>
</template>
17 changes: 17 additions & 0 deletions tests/data/glimmer-ts.gts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 17 lines, 10 code, 4 comments, 3 blanks
import type { TemplateOnlyComponent } from '@glimmer/component';

// A single-line comment
const localVariable = 'foo';

/**
* A multi-line comment
*/
const Greet: TemplateOnlyComponent<{ name: string }> = <template>
<p>Hello, {{@name}}! {{localVariable}}</p>
<style>
p {
background-color: #E04E39;
}
</style>
</template>