Skip to content
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

Validate template method to check if template can be parsed #254

Open
chaseadams509 opened this issue Sep 13, 2022 · 1 comment
Open

Validate template method to check if template can be parsed #254

chaseadams509 opened this issue Sep 13, 2022 · 1 comment

Comments

@chaseadams509
Copy link

I am considering using Inja for a project because it's a very nice C++ templating tool. However, the project takes in user-generated content, which means a high possibility of invalid templates. This makes handling exceptions being thrown very cumbersome each time a user passing in an invalid template.

Would it be possible to create a method that validates the templates and returns even a simple boolean (where it failed would be ideal, but not necessary)? This way, I could validate the template before trying to parse and render it?

@pantor
Copy link
Owner

pantor commented Dec 4, 2022

Hi @chaseadams509! Would a simple try-catch block work in this case? If not, would it just be for convenience?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants