-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There should be a configuration option to throw if a tag finds no match in the source #651
Comments
I agree with this request. My workaround for now is that I have a utility that can extract the required data structure from a template, which I can then use to validate the data, rather than making it the job of the compiler. See the gist here: https://gist.github.com/showell/7793101 |
👍 (I would say that this should be the default) |
I'd say the default should be a warning, maybe with console.warn if available, not an error; but the concept is great. |
Mustache already has a test mechanism Plus it does not match mustach specs. Why not an option, certainly not a warning or a default behaviour IMO. |
One idea could be a simple tester:
That way it's not core to the rest of the Handlebars code, allows the ability to test schema's against an actual template, and keeps current behavior. Only issue I can see is that the compiler may need to be changed to allow collation of the variables. |
Causes templates to throw when lookup fields are not defined within the context. Strict mode will throw when any field is omitted. assumeObjects mode maintains the existing behavior of outputting an empty response when fields are not defined but allows for performance/size optimizations by not doing safety checks for intermediate objects in the lookup chain. Strict mode effectively disables the helperMissing and inverse handling for blockHelperMissing as templates will throw rather than call those features for missing data fields. Fixes #651 Fixes #805
Closing in favor of #932 |
Converted @showell's gist to TypeScript, in case it helps anyone: https://gist.github.com/ajs139/f84ccbe5678ef1497a53965cc326b452 |
Given data with a missing property represented in the source, it should be configurable to have this throw.
The text was updated successfully, but these errors were encountered: