class MalleableUndefined(Undefined):

    def __getitem__(self, key):
        return self

def __getattr__(self, key):
    return self


class CustomFlask(Flask):

    def create_jinja_environment(self):
        self.jinja_options = ImmutableDict(undefined=MalleableUndefined, **
            self.jinja_options)
How to make Jinja2 convert all UndefinedError exceptions to blank strings?