fix namespace error
avoid invocation of python builtin
workaround lack of hasattr in jinja