Search code examples
htmldreamweaverpyramidchameleontemplate-tal

ParseError: Unexpected end tag - How to clean html tags?


I'm starting to learn web development and am using pyramid with chameleon. I just took some sites html source as a template in Dreamweaver and then copied the code into a chameleon .pt file.

The html code displays fine in dreamweaver but I get this error when running it in pyramid:

chameleon.exc.ParseError
ParseError: Unexpected end tag.

 - String:     "</div>"

I have tried dreamweavers cleanup function and it said it removed 2 empty tags but I still get this error. My traceback is all related to errors in the chameleon and doesn't show the specific line its having problems with in my template itself.

Is there a way to identify the actual line where the error is occurring?

I'm not sure if there's a pyramid or chameleon specific solution or if there are general methods to find errors in HTML tag.


Solution

  • Chameleon expects templates to be well-formed, and is less forgiving of unbalanced tags and incorrect attribute markup as DreamWeaver is.

    Note that the error doesn't necessarily mean that there is a </div> tag too many. If the opening <div> has a syntax error such as a missing = on an attribute declaration (e.g. <div class"foobar"> then the opening tag is not recognized and the corresponding closing tag is going to be flagged as well.

    You could run your template through an XML validator, there are several available online (such as http://www.validome.org/xml/, http://www.xmlvalidation.com/ and http://xmlgrid.net/, Google lists many more). These are bound to give you a slightly more helpful message as to what is wrong with your template.