Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Add option to validate templates using jinja2schema #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kx-chen
Copy link
Contributor

@kx-chen kx-chen commented Dec 12, 2018

Use jinja2schema to validate templates when --validate-templates
is passed in.

Closes #99

@kx-chen kx-chen force-pushed the jinja2schema-validation branch 2 times, most recently from 75b77fb to cb41734 Compare December 15, 2018 11:44
statik/cmdline.py Outdated Show resolved Hide resolved
statik/project.py Outdated Show resolved Hide resolved
statik/views.py Outdated Show resolved Hide resolved
statik/utils.py Outdated
% (item, template))
except Exception as e:
logger.warning(
"Template validation failed (likely an issue with jinja2schema): %s: %s",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the except so that it only catches errors in one line result = to_json_schema(infer(stripped_template)) and then change the warning to explicitly indicate the problem is within jinja2schema. Something like "Template inspection using jinja2schema failed: .."

Usually, only do one thing within try/except blocks. Then add another exception block to catch the next type of error.

Use jinja2schema to validate templates when --validate-templates
is passed in.

Closes thanethomson#99
@kx-chen kx-chen force-pushed the jinja2schema-validation branch from cb41734 to 3f93889 Compare December 18, 2018 17:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants