Skip to content

Commit 098a009

Browse files
CISCgradio-pr-bot
andauthored
Add Jinja2 language to Code component (#9545)
* Add jinja2 codemirror language * add jinja2 * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent d826faa commit 098a009

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

.changeset/mighty-goats-dance.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/code": minor
3+
"gradio": minor
4+
---
5+
6+
feat:Add Jinja2 language to Code component

gradio/components/code.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Code(Component):
2929
"html",
3030
"css",
3131
"javascript",
32+
"jinja2",
3233
"typescript",
3334
"yaml",
3435
"dockerfile",
@@ -69,6 +70,7 @@ def __init__(
6970
"html",
7071
"css",
7172
"javascript",
73+
"jinja2",
7274
"typescript",
7375
"yaml",
7476
"dockerfile",

js/code/shared/language.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const possible_langs = [
1212
"html",
1313
"css",
1414
"javascript",
15+
"jinja2",
1516
"typescript",
1617
"yaml",
1718
"dockerfile",
@@ -58,6 +59,10 @@ const lang_map: Record<string, (() => Promise<Extension>) | undefined> = {
5859
css: () => import("@codemirror/lang-css").then((m) => m.css()),
5960
javascript: () =>
6061
import("@codemirror/lang-javascript").then((m) => m.javascript()),
62+
jinja2: () =>
63+
import("@codemirror/legacy-modes/mode/jinja2").then((m) =>
64+
StreamLanguage.define(m.jinja2)
65+
),
6166
typescript: () =>
6267
import("@codemirror/lang-javascript").then((m) =>
6368
m.javascript({ typescript: true })

0 commit comments

Comments
 (0)