MemberJunction / MemberJunction/MJ
[Explorer] Template editor requests unregistered 'jinja2' language — template bodies render with no syntax highlighting
- Dominant language
- TSQL
- Stars
- 29
- Forks
- 6
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 323
Description
## Summary
The Template editor asks the shared code editor for the `jinja2` language, but `jinja2` is not in the editor's registered language list. The lookup fails, logs to the console, and the editor silently falls back to **no syntax highlighting** for template content.
```
console.error: Language not found: jinja2
```
## Where
Requested in two places (both hardcode `'jinja2'` as the default for template bodies):
- [`packages/Angular/Explorer/core-entity-forms/src/lib/shared/components/template-editor.component.ts`](https://github.com/MemberJunction/MJ/blob/next/packages/Angular/Explorer/core-entity-forms/src/lib/shared/components/template-editor.component.ts) — L452, L460, L478
```typescript
return 'jinja2'; // default to jinja2 for template syntax (compatible with Nunjucks)
```
- [`packages/Angular/Explorer/core-entity-forms/src/lib/custom/Templates/templates-form.component.ts`](https://github.com/MemberJunction/MJ/blob/next/packages/Angular/Explorer/core-entity-forms/src/lib/custom/Templates/templates-form.component.ts) — L508, L516
Resolved (and rejected) in [`packages/Angular/Generic/code-editor/src/lib/ng-code-editor.component.ts`](https://github.com/MemberJunction/MJ/blob/next/packages/Angular/Generic/code-editor/src/lib/ng-code-editor.component.ts) `_findLanguage()` ~L717–728:
```typescript
private _findLanguage(name: string) {
for (const lang of this.languages) {
for (const alias of [lang.name, ...lang.alias]) {
if (name.toLowerCase() === alias.toLowerCase()) { return lang; }
}
}
console.error('Language not found:', name);
console.info('Supported language names:', this.languages.map((lang) => lang.name).join(', '));
return null;
}
```
The caller then does `langDesc?.load()` — the optional chain swallows the `null`, so nothing is configured and the editor stays unhighlighted.
## Impact
Low severity, but user-visible: **MJ Template bodies get no syntax highlighting**, which is precisely the content that most benefits from it. Observed 4× in regression run `run-20260727T202606Z`, on the template-touching tests T037, T043, T125.
## Suggested fix direction
Either register a `jinja2` language (CodeMirror's `@codemirror/language-data` has no jinja2 entry; `StreamLanguage` + the legacy `jinja2` mode from `@codemirror/legacy-modes/mode/jinja2` is the usual route), or map the request to an existing supported language so template bodies at least get *some* highlighting.
Separately worth considering: `_findLanguage` returning `null` is currently a silent no-op for the caller. Falling back to a plain-text/default language would make the failure mode less invisible than "highlighting just doesn't work."
---
*Found by the MJ Explorer Computer Use regression suite, run `run-20260727T202606Z` (2026-07-27).*
Contributor guide
Research direction
Start with template-editor.component.ts and templates-form.component.ts, then read _findLanguage() in ng-code-editor.component.ts to understand the failed lookup and its caller. Reproduce the issue with the template-related regression cases T037, T043, and T125 from run-20260727T202606Z. Done means template bodies receive syntax highlighting without the “Language not found: jinja2” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100