-
-
Notifications
You must be signed in to change notification settings - Fork 393
Description
Hi,
First, thank you for this project - It has been super useful for my use-case.
I wanted to bring up the topic of optional strong/static typing, or static analysis for Scriban to see if anyone else has considered this.
In our project we have the problem that when making changes to the template, we make mistakes that become apparent only under certain conditions at runtime. Here's an example
class Person {
string Name;
Person[] Friends;
}
Here are the friends of {{ person.name }}
{{ for friend in person.friends }}
{{ friend.namee }} <- Typo here
{{ end }}
We have all the possible "strict" checks turned on
StrictVariables = true,
EnableRelaxedFunctionAccess = false,
EnableRelaxedIndexerAccess = false,
EnableRelaxedMemberAccess = false,
EnableRelaxedTargetAccess = false,
The problem is that, the example template above throws an exception only if the array person.Friends is non-empty. For this toy example it would be simple to set up a unit test that exercises the loop. However, once a template gets complex with execution multiple branches, it's hard to remember to add unit tests for all possible branches.
That got us thinking if we could implement some kind of static analysis to handle these kinds of errors.
Has anyone else considered this? Thanks!