- Introduced a new language support for EJS templates with XML integration, allowing for custom scriptlets and improved syntax highlighting. - Updated CodeBlockEditor and TemplateEditor components to utilize the new fcTemplateLang for EJS language handling. - Modified DocumentTemplate model to reflect the new language type for content. - Added necessary grammar and parser files for fcTemplateLang, enhancing the overall template editing experience.
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
// FarmControl EJS outer grammar for fcTemplateLang.
|
|
// Regenerate the parser with:
|
|
// pnpm exec lezer-generator src/codemirror/fcTemplateLang/ejs.grammar --output src/codemirror/fcTemplateLang/ejs.parser.js
|
|
//
|
|
// Outer language = EJS scriptlets; Text regions are overlaid with XML and
|
|
// JavascriptExpression nodes are mounted with the JS parser (parseMixed).
|
|
|
|
@top Template { content* }
|
|
|
|
content {
|
|
Scriptlet |
|
|
Output |
|
|
Comment |
|
|
Text
|
|
}
|
|
|
|
Scriptlet { OpeningTag JavascriptExpression ClosingTag }
|
|
Output { OutputTag JavascriptExpression ClosingTag }
|
|
|
|
@skip {} {
|
|
Comment { CommentTag (CommentContent | commentNewLine)* commentEnd }
|
|
}
|
|
|
|
@local tokens {
|
|
commentEnd { ClosingTag }
|
|
commentNewLine { "\n" }
|
|
@else CommentContent
|
|
}
|
|
|
|
@tokens {
|
|
// Prefer longer tags via @precedence below
|
|
OpeningTag[closedBy=ClosingTag] { "<%" }
|
|
OutputTag[closedBy=ClosingTag] { "<%=" | "<%-" | "<%_" }
|
|
CommentTag[closedBy=ClosingTag] { "<%#" }
|
|
ClosingTag[openedBy="OpeningTag OutputTag CommentTag"] { ("-" | "_")? "%>" }
|
|
|
|
@precedence { OutputTag, CommentTag, OpeningTag }
|
|
}
|
|
|
|
@external tokens javascriptExpressionOrText from "./tokens.js" {
|
|
JavascriptExpression,
|
|
Text
|
|
}
|
|
|
|
@detectDelim
|