Add support for nested templates
Add support for expressions inside expressions.
Add support for templating where the output of one expression results in
another template part with expressions.
E.g., this did not work before, but compilation will now evaluate both
with expression with `$condition` and parameter substitution with
`$text`:
```
{{ with $condition }}
echo '{{ $text }}'
{{ end }}
```
Add also more sanity checks (validation logic) when compiling
expressions to reveal problems quickly.
This commit is contained in:
@@ -13,4 +13,22 @@ export class ExpressionPosition {
|
||||
throw Error(`negative start position: ${start}`);
|
||||
}
|
||||
}
|
||||
|
||||
public isInInsideOf(potentialParent: ExpressionPosition): boolean {
|
||||
if (this.isSame(potentialParent)) {
|
||||
return false;
|
||||
}
|
||||
return potentialParent.start <= this.start
|
||||
&& potentialParent.end >= this.end;
|
||||
}
|
||||
|
||||
public isSame(other: ExpressionPosition): boolean {
|
||||
return other.start === this.start
|
||||
&& other.end === this.end;
|
||||
}
|
||||
|
||||
public isIntersecting(other: ExpressionPosition): boolean {
|
||||
return (other.start < this.end && other.end > this.start)
|
||||
|| (this.end > other.start && other.start >= this.start);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user