Add multiline support for with expression

Improve templating support for block rendering for `with` expression
that has multiline code. This improves templating support to render
multiline code conditionally.

This did not work before but works now:

```
{{ with $middleLine }}
  first line
  second line
{{ end }}
```
This commit is contained in:
undergroundwires
2022-10-02 20:12:49 +02:00
parent 7d3670c26d
commit e8d06e0f3e
6 changed files with 136 additions and 31 deletions

View File

@@ -25,10 +25,10 @@ export class ExpressionRegexBuilder {
.addRawRegex('([^|\\s]+)');
}
public matchAnythingExceptSurroundingWhitespaces() {
public matchMultilineAnythingExceptSurroundingWhitespaces() {
return this
.expectZeroOrMoreWhitespaces()
.addRawRegex('(.+?)')
.addRawRegex('([\\S\\s]+?)')
.expectZeroOrMoreWhitespaces();
}

View File

@@ -12,7 +12,7 @@ export class WithParser extends RegexParser {
.matchUntilFirstWhitespace() // First match: parameter name
.expectExpressionEnd()
// ...
.matchAnythingExceptSurroundingWhitespaces() // Second match: Scope text
.matchMultilineAnythingExceptSurroundingWhitespaces() // Second match: Scope text
// {{ end }}
.expectExpressionStart()
.expectCharacters('end')