defunkt/pystache — pull request #140 by bennoleslie (2013-01-02 09:12:34+00:00)
Title: Append file:line.col information to strict exceptions.

When debugging a complex (or simply long) template it is very
useful to the exact location causing errors.

This adds a 'location' field to appropriate exception objects
which can then be displayed to the user by appropriate error
handling code.

The current design is backwards compatible, and the filename
that is encoded in the location object defaults to ''
unless specifically overridden by the user.

This patch opens the scope for more intelligent defaults
throughout the library, however this patch tries to avoid
significant changes to the external API.

Currently to take advantage of the changes a ParsedTemplate
object must be manually created using the parser._Parser.parse
method, which has a second (optional) argument 'name'. This
name is copied through to the exception's location field in
the case of an error.

There is a large design scope for the way in which this may
be implemented. The current approach tries to balance the
propagation of location objects through the API, while avoiding
too much duplication of code.