Added missingLocal
option to define how to handle missing local value
#138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Previously in case a value for a referenced local was missing the string 'undefined' was inserted in the output EXCEPT if it was used in an expression like
{{missingLocal ? 'yes' : 'no'}}
when an exception is thrown.I was tying to create a opportunity for developers to decide how to handle such situation.
The default behavior is changed: when
strictMode
is true (default) and leaving the newmissingLocal
optionundefined
, then the same "'foo' is not defined" exception is thrown as when a referenced value is missing in an expressionSetting
strictMode
false and leaving the newmissingLocal
optionundefined
results the previous result:undefined
Setting the new
missingLocal
option to a string will produce that string in the output regardless the value ofstrictMode
.missingLocal
can contain the placeholder{local}
which will be replaced with the name of the missing local in the output. This solution allows tomissingLocal
to""
locals
like "#Missing value: {local}"See updated README and test cases
Types of Changes
What types of changes does your code introduce
Checklist
Further Comments
If this is a large or complex change, kick off the discussion by explaining why
you chose the solution you did and what alternatives you considered, etc...
Reviewers: @mrmlnc, @jescalan, @michael-ciniawsky, @posthtml/collaborators