Page Variations
Dear Lazyweb,
Is there a tool somewhere that will automatically generate and validate all possible output variations for a Django HTML template page? We’re using Django in Basie, and have been running into problems when one branch of a conditional closes a tag, but the other doesn’t:
<li>opening text
{% if something %}
blah blah
</li>
{% else %}
Whoops, forgot to close the list element.
{% endif %}
I know that code review should catch these, but when the examples are longer, it’s hard to keep track of as-yet unclosed tags. Testing should catch them too, but sometimes people forget to write as many test as they should *cough* *cough*. So, is there something that will parse the HTML templates, generate all possible variations, and check that they’re valid? It wouldn’t have to generate all possible cross-products (at least, I don’t think it would), so runtime would be manageable.
Thanks in advance.
Don’t know Django but could you put the close tag at the end?
i.e
opening text
{% if something %}
blah blah
{% else %}
Whoops, forgot to close the list element.
{% endif %}
@Chris In this case, sure, but in longer cases, it’s not always easy/natural to do that.
It’s not really what you want, but you might be interested: abstract parsing.
Templates should be easier to analyze than arbitrary programs, however.
Eh, look at this: Validator App for Django — “This simple app does validation on all the HTML generated by your Django app, and keeps track of any pages that fail.” Would be great to leave on during Basie’s development.