Raise Exception on invalid template variable

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# settings.py
class InvalidVarException(object):
    def __mod__(self, missing):
        try:
            missing_str=unicode(missing)
        except:
            missing_str='Failed to create string representation'
        raise Exception('Unknown template variable %r %s' % (missing, missing_str))
    def __contains__(self, search):
        if search=='%s':
            return True
        return False

TEMPLATE_DEBUG=True
TEMPLATE_STRING_IF_INVALID = InvalidVarException()

Comments

guettli (on September 30, 2008):

Related ticket: #6766

#

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.