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

feature request: Template Validator / Tests #151

Open
jvanasco opened this issue Sep 6, 2013 · 0 comments
Open

feature request: Template Validator / Tests #151

jvanasco opened this issue Sep 6, 2013 · 0 comments

Comments

@jvanasco
Copy link

jvanasco commented Sep 6, 2013

It would be great if pystache had a tool to properly validate a template.

I slapped this together , but it could be wrong. I don't know the internals correctly, and tried to break templates a few ways.

import types
    import pystache

def validate_template(unicode_string):
    if not isinstance( unicode_string , types.UnicodeType ):
        return False
    try:
        pystache.parse(unicode_string)
        return True
    except:
        return False

It would just be great to check templates for the correct syntax , this way my applications' unit tests can always ensure that templates are valid ( without having to generate sample data and render them ).

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

No branches or pull requests

1 participant