Language support for jsonte (JSON Templating Engine) files used in Minecraft Bedrock add-on projects.
.templ— jsonte templates.modl— jsonte modules ($module, used through$extend).jsonte— standalone jsonte scripts (scope scripts,$scope.x = ...)#{...}expressions inside.molangand.mcfunctionfiles and##{...}inside.langfiles (highlighting, hover, completion and syntax diagnostics are injected into those languages)
- JSON-based TextMate grammar with dedicated scopes for reserved keys (
$template,$extend, ...), override/prepend merge keys ($key,^key) and$molang:keys - Semantic highlighting of
{{...}}expressions and.jsontescripts driven by the engine's ANTLR lexer (keywords, operators, numbers, strings, functions, variables, lambda parameters, comments) - Background decoration for expressions (
jsonte.editor.expressionBackground) and bracket matching inside expressions
Existing JSON schemas are applied to .templ and .modl files so that Bedrock add-on schemas keep working on templated files:
- schemas from
json.schemas,jsonte.validation.schemasandcontributes.jsonValidationof installed extensions (for example the Blockception Minecraft Bedrock Development extension) .templ/.modlfiles are matched as if they were the corresponding.jsonfile, soentity.jsonpatterns also coverentity.json.templandentity.templ- the value of top-level
$templateis validated against the schema (jsonte.validation.unwrapTemplateKey) $key,^keyand$molang:keyare validated askey;$commentand$assertare never reported as unknown properties- properties inherited from
$copyfiles and$extendmodules count towardsrequiredchecks - whole-value
{{=...}}expressions that resolve to literals or scope values are validated with their real type - diagnostics under iteration/condition action keys (
{{#...}},{{?...}}) and around unresolved expressions are downgraded or hidden (jsonte.validation.dynamicTolerance) - schema-driven completion and hover, including
$extendmodule name completion from workspace.modlfiles jsonte: Go to Schemaopens the schema matched for the current file
- expression syntax errors from the engine grammar (
{{...}},#{...},##{...}, template strings,.jsontescripts) - unmatched or empty
{{ }}delimiters - misplaced action directives (
{{#...}}/{{?...}}must be the whole key and start right after{{) - malformed merge keys (
$/^without a name, template expression as the base key) $modulein.templfiles, missing$modulein.modlfiles- unknown scope property access (
data.missing) based on the project scope
Scope files from the Regolith packs/data/jsonte folder (JSON files and .jsonte scripts) provide:
- completion and hover for scope variables and scope-defined lambdas, with JSONC comments shown as documentation
- static resolution of scope values in schema validation
- built-in function completion and hover documentation (generated from the engine sources)
- directive completion (
#,?,=) at the start of key expressions - snippets:
jtefor,jteforas,jteif,jtelit - JSON formatting for
.templ/.modl, selection range expansion,{{ }}auto-closing
| Setting | Default | Description |
|---|---|---|
jsonte.validation.enableSemanticDiagnostics |
true |
jsonte-specific diagnostics for template, module and embedded files |
jsonte.validation.enableSchemaOnTempl |
true |
Validate .templ/.modl against matching JSON schemas |
jsonte.validation.unwrapTemplateKey |
true |
Validate the value of top-level $template instead of the whole file |
jsonte.validation.schemas |
[] |
Extra schema mappings in the json.schemas shape |
jsonte.validation.dynamicTolerance |
warn |
off / warn / ignore handling of schema errors caused by dynamic expressions |
jsonte.validation.engineEvaluation |
off |
onDemand / always lets validation resolve {{=...}} values with the jsonte CLI (trusted workspaces only) |
jsonte.validation.enginePath |
jsonte |
Executable used when engine evaluation is enabled |
jsonte.validation.engineTimeoutMs |
100 |
Timeout per engine call |
jsonte.editor.expressionBackground |
subtle |
off / subtle / strong background for {{...}} expressions |
If files.associations maps *.templ or *.modl to another language (for example json), the extension offers to remove the override, because schema support only works with the jsonte languages.
npm install
npm run build
npm testLaunch an Extension Development Host with F5 (optionally with the Bedrock extension enabled) or:
npm run test:manual # extension only
npm run test:manual:bedrock # with the Blockception Bedrock extension enabledPass -Workspace <path> to scripts/launch-dev-host.ps1 to open a real add-on project instead of this repository.
- ANTLR parser/lexer: copy
JsonTemplate.g4andJsonTemplateLexer.g4from the engine'sgrammar/folder intogrammar/and runnpm run generate:antlr(requires Java). - Built-in function catalog:
npm run generate:functions -- --source <engine>/jsonte/functions. - Snapshot tests:
npm run test:update-snapshotsafter reviewing the new output.
MIT